[問題] List<Struct> 可以當成參數傳遞嗎

看板C_Sharp (C#)作者 (摳屁蛋)時間13年前 (2012/06/07 23:18), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/2 (看更多)
如標題,如果我有兩個程式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
就List<Struct> 變數名
06/07 23:39, 1F

06/07 23:40, , 2F
原來有人回了
06/07 23:40, 2F

06/07 23:48, , 3F
感恩 原來是我不同cs檔的路徑放錯了....
06/07 23:48, 3F
文章代碼(AID): #1FqCPVZ9 (C_Sharp)
文章代碼(AID): #1FqCPVZ9 (C_Sharp)