[問題] class 中的field轉string array
請問一下
我現在有個class如下
class Test
{
public string AAA{get;set;}
public string BBB{get;set;}
}
再來有個test的list
List<Test> test;
最後是有個string list
List<List<string>> output;
我要把AAA的內容放到output[0]
BBB放到output[1];
我現在只想到
output[0] = test.Select(x=>x.AAA).ToList<string>();
output[1] = test.Select(x=>x.BBB).ToList<string>();
如果我這個class中的field有 十個我就要寫十行
覺得有點麻煩耶!
有沒有什麼寫法可以再縮減的啊?
謝謝大家!
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.32.241.230
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1428495998.A.6F1.html
推
04/08 20:38, , 1F
04/08 20:38, 1F
→
04/08 21:23, , 2F
04/08 21:23, 2F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章