c# 匿名函数和lamda表达式语法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _07匿名函数和lamda表达式语法
{
    public delegate void DelTest1();
    public delegate string DelTest2();
    public delegate string DelTest3(string str);
    class Program
    {
        static void Main(string[] args)
        {
            //DelTest1 del1 = T1;指向普通的函数
            //DelTest1 del2 = delegate() { };匿名函数
            //DelTest1 del3 = () => { };lamda表达式


            //DelTest2 del1 = T2;
            //DelTest2 del2 = delegate() { return null; };
            //DelTest2 del3 = () => { return null; };


            //DelTest3 del1 = T3;
            DelTest3 del2 = delegate(string str) { return null; };
            DelTest3 del3 = (str) => { return null; };
            DelTest3 del4 = str => null;
        }

        static void T1()
        { }

        static string T2()
        {
            return null;
        }

        static string T3(string str)
        {
            return null;
        }
    }
}

 

posted on 2017-06-13 15:46  算顺网  阅读(249)  评论(0编辑  收藏  举报

导航