作者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
1F:推 Abbee:就List<Struct> 变数名 06/07 23:39
2F:→ Abbee:原来有人回了 06/07 23:40
3F:→ kobe04262002:感恩 原来是我不同cs档的路径放错了.... 06/07 23:48