-2
數組當我做了seats[] seatArray
,並嘗試運行它,我得到一個錯誤使從一個類的對象
的NullReferenceException是未處理的。你調用的對象是空的。
我認爲這是我在最後的printinfo函數。
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
Seats s = new Seats();
//Seats[] seatArray = new Seats[14]; //HEREEE
public Form1()
{
InitializeComponent();
listBox2.Items.Add("ROW# A B C D E F");
listBox2.Items.Add(" 1 " + s.PrintInfo);
// listBox2.Items.Add(seatArray[0].PrintInfo); //HEREEE
listBox1.Items.Add("Seats Filled:");
listBox1.Items.Add("Windows Available:");
listBox1.Items.Add("Regular Meals:");
listBox1.Items.Add("LowCal Meals:");
listBox1.Items.Add("Veget Meals:");
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
string test = listBox2.SelectedItem.ToString();/
//string[] div = Regex.Split(test, " ");
//textBox2.Text = div[0];
textBox2.Text = test; //
}
}
public class Seats //
{
public char A;
public char B;
public char C;
public char D;
public char E;
public char F;
public Seats()
{
A = '.';
B = '.';
C = '.';
D = '.';
E = '.';
F = '.';
}
public char Aa
{
set { A = value; }
get { return A; }
}
public char Bb
{
set { A = value; }
get { return A; }
}
public char Cc
{
set { C = value; }
get { return C; }
}
public char Dd
{
set { D = value; }
get { return D; }
}
public char Ee
{
set { E = value; }
get { return E; }
}
public char Ff
{
set { F = value; }
get { return F; }
}
public string PrintInfo //
{
get { return this.A + " " + this.B + " " + this.C + " " + this.D + " " + this.E + " " + this.F; }
}
}
}
這個問題是一個有點亂。你究竟在問什麼?我看到提到了一個'NullReferenceException'(請參閱http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it)和一些關於如何顯示屬性在文本框? –
我已經從您的代碼示例中刪除了不相關的方法(空白處沒有任何內容)。確保你**只在你的問題中包含相關信息** – Sayse