我使用Asp.net/C#
#數組訪問的問題,,我已經宣佈的integer
array
如下public int[] recno;
因爲我不知道array
的確切大小,,但是一個function
內我得到基礎上的數量以瞭解它的大小customer_id's
在table.Here是function
ç
public void GetRecordNo()
{
recid = from id in dt.cust_masters
select id;
recno = new int[recid.Count()];
for (int i = 0; i < recid.Count(); i++)
{
recno[i] = Convert.ToInt32(recid.ElementAt(i).customer_id);
}
}
當我嘗試調用一個函數ShowRecord(int index)
它接受顧客的id
以下面的方式
ShowRecord(recno[0])
它給了我一個錯誤
Object reference not set to an instance of an object.
任何人都可以點我在哪裏,我要去錯了。 感謝
你肯定有你的查詢返回VALU ES? – Maheep 2012-03-14 09:01:03
嘗試使用「from cust from dt.cust_masters select cust.id;」 – Maheep 2012-03-14 09:01:40
@Maheep它的返回值,因爲當我調用函數ShowRecord()該函數內部它工作得很好.. – freebird 2012-03-14 09:06:14