简单Linq语句查询排序

查询数组中所有偶数,按大小排序

int []nums = { 1, 8, 4, 7, 3, 2, };


           /* var Q1 = from num in nums
                     where num % 2 == 0
                     orderby num
                     select num; */
            var Q2 = nums.Where(n => n % 2 == 0).OrderBy(n=>n); //Lamda表达式
            foreach (var item in qq)
            {
                Console.WriteLine(item + "");
            }
            Console.ReadKey();

猜你喜欢

转载自blog.csdn.net/weixin_42479664/article/details/80886561
今日推荐