嘿伙计们,我想出了如何一次一行地将项目添加到列表框中:
try
{
if (nameTxtbox.Text == "")
throw new Exception();
listBox1.Items.Add(nameTxtbox.Text);
nameTxtbox.Text = "";
textBox1.Text = "";
nameTxtbox.Focus();
}
catch(Exception err)
{
MessageBox.Show(err.Message, "Enter something into the txtbox", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Run Code Online (Sandbox Code Playgroud)
但我不能在同一行添加多个项目.喜欢有first_name | last_name | DoB都在同一条线上.当我做
listBox1.Items.Add(last_name.Text);
Run Code Online (Sandbox Code Playgroud)
它将姓氏添加到列表框中的新行,我需要将其添加到与第一个名称相同的行.
我试图发送一个string从form SettingsMenu使用到我的主要形式Delegate,如下图所示的结构:
在SettingsMenu表单中委派:
delegate void ClocknameReceivedEventHandler(object sender, SettingsMenu.ClocknameReceivedEventArgs e);
Run Code Online (Sandbox Code Playgroud)
SettingsMenu类中的内部类ClocknameReceivedEventArgs:
public partial class SettingsMenu : Form
{
internal class ClocknameReceivedEventArgs : EventArgs
{
string _clockname;
public string Clockname
{
get { return _clockname; }
}
public ClocknameReceivedEventArgs(string clockname)
{
_clockname = clockname;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在代码中更多一点SettingsMenu:
public event ClocknameReceivedEventHandler ClocknameReceived;
// Invoke the Changed event; called whenever list changes
protected void OnClocknameReceived(SettingsMenu.ClocknameReceivedEventArgs e)
{
ClocknameReceived(this, e);
}
Run Code Online (Sandbox Code Playgroud)
SettingsMenu我Main form使用以下内容捕获来自我的传入数据 …
我需要删除转换为字符串的byte []的前4个句子.
到目前为止我所拥有的:
//convert bytearray to string, so I can modify the string
string rawString = Convert.ToBase64String(rawByteArray);
//seperate lines
string[] textLines = Regex.Split(rawString, "\r\n");
//I need to substract the first 4 senctences of the string here!
//convert string back to byte array
byte[] cleanByteArray = rawstring.FromBase64String(rawString);
Run Code Online (Sandbox Code Playgroud)
如何减去前4个句子?
提前致谢!
我有两个名为supply和的表equipment.这两个表有一个名为的公共字段:IAR_NO
现在,我想要的是使用单个查询进行更新,两个表中包含0的所有记录IAR_NO.
什么可能是最好的查询?
我目前正在使用但不起作用
update supply, equipment
set supply.IAR_NO = "9", equipment.IAR_NO= "9 "
where equipment.IAR_NO = 0 and supply.IAR_NO = 0
Run Code Online (Sandbox Code Playgroud) 我需要摆脱一个字符串驱动器,目录和扩展.虽然我经历的驱动器似乎无法让目录和扩展工作.
namespace ConsoleApplication1
{
class GetMethods
{
public String GetDrive(String Path)
{
String Drive;
Drive = Path.Substring(0, 2);
Console.WriteLine("Drive: {0}", Drive);
return Drive;
}
public String GetDirectory(String Path)
{
Console.WriteLine("Directorul: ");
var start = Path.IndexOf(":") + 1;
var match2 = Path.Substring(start, Path.IndexOf(".") - start);
return Path;
}
public String GetExtension(String Path)
{
String Extension;
Extension = Path.Substring(0,3);
Console.WriteLine("Extensia: {0}", Extension);
return Extension;
}
}
class Program
{
static void Main(string[] args)
{
String Path;
GetMethods G = new GetMethods();
Console.WriteLine("Introduceti …Run Code Online (Sandbox Code Playgroud) 我在存储过程中使用Sybase 15 SQL.我想在临时#table上识别索引.常用技术适用于永久表,但不适用于临时表:
--look for an index on a temporary table
create table #T1( duff int)
create index idx99 on #T1(duff)
select * from sysindexes where name = 'idx99' --returns null rows !
--Look for an index on a permanent table
create table T1( duff int)
create index idx99 on T1(duff)
select * from sysindexes where name = 'idx99' --returns a row. OK for perm table.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
短发
我正在尝试在我的餐厅评论网站上创建一个功能,以确定餐厅是否已经过审核.如果餐厅未经审核,则返回变量.但是我一直收到错误Cannot implicitly convert type 'int' to 'System.Collections.Generic.List<>'就行了if (restaurantreview = 0).
任何帮助将不胜感激.
var restaurantreview = objCtx.Reviews.Where(r => r.RestaurantId == currentrestaurant).ToList();
if (restaurantreview = 0)
{
var none = "Sorry Your Restaurant Hasnt been Reviewd Yet";
}
else
{
var averagefood = objCtx.Reviews
.Where(r => r.RestaurantId == currentrestaurant)
.Average(r => r.Food);
}
Run Code Online (Sandbox Code Playgroud) 我有2个阵列
string[] Namesvalues = Names.Split(',');
string[] TotalValues = Total.Split(',');
Run Code Online (Sandbox Code Playgroud)
上面两个数组都有完全相等的值.我想要做的是并行迭代上面两个数组,并希望从两个数组中逐个获取值.
谁能告诉我怎么办?
我正在检查我的应用程序"坏代码"使用ReSharper.
我有以下内容if-statement:
if (Utility.Compare(Utility.ExtractRangeFromArray(bufferRx, 0, bytesRead), new byte[] { U_EOT}))
{
// EOT (End of transmission) received, break from while
break;
}
Run Code Online (Sandbox Code Playgroud)
ReSharper告诉我改变:new byte[]到new[]
我的问题:什么是最好的选择?为什么我不应该声明变量?
以下是linq查询.在这里,我想添加一个条件.条件:如果:Firstname不为空,则选择list where(d => d.firstname =="Firstname") else:选择所有列表无条件
function Ponits(string Firstname)
{
pointsCore.Categories.SelectMany(c => c.Events).Select(e => new
{
e.Firstname,
e.Surname,
e.EntityNumber,
e.Eventdate
}).ToList()
}
Run Code Online (Sandbox Code Playgroud)