码迷,mamicode.com
首页 > Windows程序 > 详细

C#的匿名函数

时间:2015-09-06 06:24:22      阅读:216      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!