Getting odd/even part of a sequence with LINQ

前端 未结 7 1314
再見小時候
再見小時候 2020-12-01 06:47

Say I have a list of all Projects, and that I group them by Category like this:

var projectsByCat = from p in Projects
                     


        
7条回答
  •  感动是毒
    2020-12-01 07:19

    You Can find Even odd number without foreach loop

    static void Main(string[] args)
    {
        List lstnum = new List { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    
        List lstresult = lstnum.FindAll(x => (x % 2) == 0);
    
        lstresult.ForEach(x => Console.WriteLine(x));
    }
    

提交回复
热议问题