-4
有問題。在Program.cs中我有未將對象引用設置爲arrayList對象的實例
public static ArrayList VKgroup_VKtoOD { get; set; }
在窗體2我試圖挽救combobox1到VKgroup_VKtoOD所有項目,但收到的異常
Object reference not set to an instance of an object
代碼:
foreach (object item in comboBox1.Items)
{
Data.VKgroup_VKtoOD.Add(item);
}
爲什麼?這一個
public static ArrayList VKgroup_VKtoOD { get; set; }
:
您需要分配一個'新的ArrayList',否則屬性值爲'null' – crashmstr
你是否初始化你的數組? VKgroup_VKtoOD = new ArrayList() –
以[看看邊欄](http://i.imgur.com/HmNmwef.png)。 –