当我运行此代码时,我收到错误
指数数组的边界之外.
for (var i = 9; i + 2 < lines.Length; i += 3)
{
Items.Add(new ItemProperties {
Item = lines[i],
Description = lines[i + 1],
Quantity = lines[i + 2],
UnitPrice = lines[i + 3]
});
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮帮我吗?
我无法运行我的代码,因为有一个错误提示:
无法分配给“OnNewLand”,因为它是“方法组”
这很奇怪,因为我使用了与其他方法相同的结构,并且它们没有问题。这是我的代码。
private void CreateNewFlight()
{
string flightCode = ReadFlightCode();
//Create the new bidder
if (!string.IsNullOrEmpty(flightCode))
{
FlightWindow frm = new FlightWindow(Flightcode.Text);
frm.Show();
//Subscribe to the publisher's new bid and quit bid events
frm.NewStart += OnNewStartClick;
frm.NewChangeRoute += OnNewChangeRoute;
frm.OnNewLand += OnNewLand; <----Here is the error <-------
}
}
Run Code Online (Sandbox Code Playgroud)
无法分配给“OnNewLand”,因为它是“方法组”
我的另一个窗口:
public event EventHandler<Start> NewStart;
public event EventHandler<ChangeRoute> NewChangeRoute;
public event EventHandler<Land> NewLand;
private void btnStart_Click(object sender, RoutedEventArgs e)
{
Start startinfo = new Start(this.Title);
OnNewStart(startinfo); //Raise event
btnLand.IsEnabled …Run Code Online (Sandbox Code Playgroud) 我正在学习JavaScript而我正在努力使用,这样用户就可以输入名称和姓氏,然后单击"发送"按钮.当发生这种情况时,名称和姓氏将显示在屏幕上.
问题是它不起作用.用户单击"发送"按钮时没有任何操作.
这就是我厌倦了.
HTML:
<body>
First name:<br>
<input type="text" name="firstname">
<br>
Last name:<br>
<input type="text" name="lastname">
<br>
<input type="button" value="Send" onclick="MyFunction()">
<div id="here"></div>
<body>
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
function MyFunction() {
var first, second;
first = document.getElementById("firstname").value;
second = document.getElementById("lastname").value;
document.GetElementById("here").InnerHTML = first;
document.GetElementById("here").InnerHTML = second;
}
Run Code Online (Sandbox Code Playgroud)
我试图计算称为属性名的总和Total来GrandTotal.我想要它做的是GrandTotal计算所有的总和Total,这是我尝试的方式:
public class ItemProperties
{
public int Item { get; set; }
public string Description { get; set; }
public int Quantity { get; set; }
public int UnitPrice { get; set; }
public int Tax { get; set; }
public int TotalTax { get { return ((Quantity * UnitPrice) * Tax) /100 ; } }
public int Total { get { return (Quantity * UnitPrice) + TotalTax; } }
public int …Run Code Online (Sandbox Code Playgroud) 当用户在消息框上单击"是"时,我正在尝试删除所有元素,但我不确定如何删除按钮上的所有项目.我能够删除索引处的元素,但不能删除所有元素.
这是我成功删除索引元素的方法:
public void DeleteAt(int anIndex)
{
if(CheckIndex(anIndex))
m_list.RemoveAt(anIndex);
}
Run Code Online (Sandbox Code Playgroud)
但我想删除所有元素.我试过这样做:
public void DeleteAll()
{
m_list.RemoveAll();
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用,它说需要有一个参数,RemoveAll();但我不知道什么样的参数.