using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _01匿名方法
{
class Program
{
delegate void speak();
static void Main(string[] args)
{
speak Speak = delegate { Console.WriteLine("你好小清"); };
Action act = () => Console.WriteLine("你好冬清");//Lambda表达式
Speak();
act();
Action Speaks = delegate { Console.WriteLine("清"); };
Speaks();
//声明匿名方法和正常方法一样,只不过需要写对委托
Action<string> spe = delegate (string str) { Console.WriteLine("你好" + str); };
Action<string> spr = (string srp) => Console.WriteLine("
.NET c#匿名方法
最新推荐文章于 2019-08-17 20:47:33 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)