作者kobe04262002 (摳屁蛋)
看板C_Sharp
標題[問題] List<Struct> 可以當成參數傳遞嗎
時間Thu Jun 7 23:18:53 2012
如標題,如果我有兩個程式A和B
A程式運作完產生一個List<Struct>
B接著要將List<Struct>內的資料繼續處理
那麼A要如何將整個List傳給B呢??
謝謝
大致上程式碼如下:
struct Item
{
private string sName;
private string sValue;
public string Name { get; set; }
public string Value { get; set; }
}
public int A()
{
Item iItem = new Item();
ListTest lListTest = new ListTest();
List<Item> DataList = new List<Item>();
iItem.Name = "PC";
iItem.Value = "1-1";
DataList.Add(iItem);
iItem.Name = "PC";
iItem.Value = "1-2";
DataList.Add(iItem);
iItem.Name = "PC";
iItem.Value = "1-3";
DataList.Add(iItem);
B(DataList);
}
public int B(/*這邊不曉得要怎麼宣告*/)
{
.......
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.234.248
推 Abbee:就List<Struct> 變數名 06/07 23:39
→ Abbee:原來有人回了 06/07 23:40
→ kobe04262002:感恩 原來是我不同cs檔的路徑放錯了.... 06/07 23:48