作者rex1224 (魔王宗佑)
看板C_Sharp
标题Re: [问题] List<Struct> 可以当成参数传递吗
时间Thu Jun 7 23:36:38 2012
※ 引述《kobe04262002 (抠屁蛋)》之铭言:
: 如标题,如果我有两个程式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(List<Item> _DataList)
{
.......
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.167.44.208
1F:→ kobe04262002:已经解决 谢谢你 06/07 23:48