
本文共 2803 字,大约阅读时间需要 9 分钟。
���������������
���������������������������������������������������������������������������������������������������������������������if-else���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������
������������������������������new���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GreetingDelegate������������������ChineseGreeting���������
GreetingDelegate g1 = new GreetingDelegate(ChineseGreeting);
���������������������������g1("������")���������������������������
g1("������");
������������
C#������������������������������������Action���Func���������������������������������������
-
Action������������������������������������������������������������������������������������������������������������Action
(params T[])��������������������������������������� -
Func������������������������������������������������������������������������������������������Func
(params T[])���������������������������������������������������������������������������
������������������������������������������������������������������
// Action������Actionaction = name => Console.WriteLine("���������" + name);action("Tom");// Func������Func calculate = (x, y) => x + y;int result = calculate(100, 200);// ��������� FuncFunc assertTrue = (value, expected) => value == expected;bool result trovato = assertTrue("Hello", true);
������������
������������������������������������������������������������������������������+������������������������������������������������������-������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������
// ���������������������������������������public delegate void DrawEvent(IDrawable drawable, string operation);// ���������������������������������������IDrawable d1 = new Draw { StuID = 1 };IDrawable d2 = new Draw { StuID = 2 };// ���������������������DrawEvent event1 = new DrawEvent(d1, "draw cat");DrawEvent event2 = new DrawEvent(d2, "draw dog");DrawEvent event3 = new DrawEvent(d1, "draw dog");// ������������������������event1 += event2;event1 += event3;// ������������event1();
������
���������������C#������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������C#���������������������������������������������
���������https://pan.baidu.com/s/19C_qxIT5uX7YAsmDU9Qckg ������������tnni
发表评论
最新留言
关于作者
