2016-12-13 62 views

回答

3

你可以使用LINQ到所有的字符串隔離:

IEnumerable<string> allStrings = 
    n.SelectMany(list => list); 

有了這個程序,你可以自由地做任何你喜歡的,其中包括打印所有的人。

您也可以在打印之前利用LINQ執行其他字符串操作。例如,要刪除重複,你可以使用Distinct,對他們進行排序,你可以使用OrderBy

IEnumerable<string> strings = 
    n.SelectMany(list => list) 
     .Distinct() 
     .OrderBy(s => s);