Getting odd/even part of a sequence with LINQ

前端 未结 7 1301
再見小時候
再見小時候 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<int> lstnum = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    
        List<int> lstresult = lstnum.FindAll(x => (x % 2) == 0);
    
        lstresult.ForEach(x => Console.WriteLine(x));
    }
    
    0 讨论(0)
提交回复
热议问题