• 使用委托参数的实例


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    /*使用委托参数的实例
     * 1、Func是Linq的预定义的委托类型
     * 2、public delegate TR Func<TR>();//TR 为返回类型
     * 3、public delegate TR Func<T1,TR>(T1 a1);//TR 为返回类型,<T1,TR>是类型参数,(T1 a1)是方法参数
     */
    namespace LinqFunc
    {
        class Program
        {
            static bool IsOdd(int x)
            {
                return x % 2 == 1;
            }
            static void Main(string[] args)
            {
                int[] Array = new int[] { 3,2,4,56,6,14,53};
                Func<int,bool>mtDel=new Func<int,bool>(IsOdd);
                var countOdd = Array.Count(mtDel);
                Console.WriteLine("The Count of odd numbers:{0}", countOdd);
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    20191017-1 每周例行报告
    20191010-2 每周例行报告
    20190919-1 每周例行报告
    彭思雨20190919-3效能分析
    zipfile
    subprocess
    configparser
    hashlib
    json & pickle
    headpq
  • 原文地址:https://www.cnblogs.com/sulong/p/4814895.html
Copyright © 2020-2023  润新知