Console.WriteLine and generic List

后端 未结 9 1232
长发绾君心
长发绾君心 2020-11-29 01:53

I frequently find myself writing code like this:

List list = new List { 1, 3, 5 };
foreach (int i in list) {
    Console.Write(\"{0}\\t         


        
9条回答
  •  孤街浪徒
    2020-11-29 02:26

            List a = new List() { 1, 2, 3, 4, 5 };
            a.ForEach(p => Console.WriteLine(p));
    

    edit: ahhh he beat me to it.

提交回复
热议问题