[問題] List<Struct> 可以當成參數傳遞嗎
如標題,如果我有兩個程式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
推
06/07 23:39, , 1F
06/07 23:39, 1F
→
06/07 23:40, , 2F
06/07 23:40, 2F
→
06/07 23:48, , 3F
06/07 23:48, 3F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章