委托
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace delegate_test
{
class Program
{
public delegate void DeleSayHi(string str_name);
static void Main(string[] args)
{
SayEnglish("张三");
Test("彭菊菊", SayChinese);
Test("fxx", SayEnglish);
Console.ReadKey();
}
public static void Test(string str_name, DeleSayHi del)
{
del(str_name);
}
public static void SayChinese(string str_name)
{
Console.WriteLine($"我是{str_name}");
}
public static void SayEnglish(string str_name)
{
Console.WriteLine($"My name is {str_name}");
}
}
}
匿名函数
网友评论