首页 > Windows开发 > 详细

C#的匿名函数

时间:2015-09-06 06:21:04      阅读:351      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;

namespace codeTest
{
    class Program
    {
        delegate int myDeletegate(int args0);

        delegate TResult myFunc<Targ0, TResult>(Targ0 arg0);

        static void Main(string[] args)
        {
            myDeletegate my = new myDeletegate(ShowNumber);
            //c# 2.0   Anonymous Method
            myDeletegate myA = delegate(int args0) { return args0; };
            //c# 3.0   expression
            myDeletegate myB = (x) => { return x; };

            myFunc<int, int> myC = (x) => { return x; }; 
            Console.WriteLine(my(10));
            Console.WriteLine(myA(10));
            Console.WriteLine(myB(10));
            Console.WriteLine(myC(10));
            Console.ReadLine();
        }

        static int ShowNumber(int args0)
        {
            return args0;
        }
    }






}

 

C#的匿名函数

原文:http://www.cnblogs.com/lgxlsm/p/4784352.html

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