首页 > 其他 > 详细

Linq中Lanbda表达式做参数

时间:2015-09-17 01:10:05      阅读:192      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lanbda表达式做参数
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Array = new int[] { 3, 2, 4, 56, 6, 14, 53 };
            Func<int, bool> mtDelB = delegate(int x) { return x % 2 == 1; };//匿名方法
            var countOddA = Array.Count(x => x % 2 == 1);//Lambda表达式
            var countOddB = Array.Count(mtDelB);
            Console.WriteLine("A:The Count of odd numbers:{0}", countOddA);
            Console.WriteLine("B:The Count of odd numbers:{0}", countOddB);
            Console.ReadKey();
        }
    }
}

Linq中Lanbda表达式做参数

原文:http://www.cnblogs.com/sulong/p/4814923.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!