C#.NET 定义动态对象dynamic以及属性和方法
C#.NET 定义动态对象dynamic以及属性和方法
C# Code:
//定义动态对象,以及属性和方法
dynamic a = new
{
Name = "www.cscode.net:C/S框架网",
ShowMessage = new DoSomething((object o) => MessageBox.Show(o.ToString())),
Calc = new DoCalc((int x, int y) => x+y)
};
a.ShowMessage(a.Name);
int result = a.Calc(100, 200);
//来源:C/S框架网(www.csframework.com) QQ:1980854898
//定义动态对象,以及属性和方法
dynamic a = new
{
Name = "www.cscode.net:C/S框架网",
ShowMessage = new DoSomething((object o) => MessageBox.Show(o.ToString())),
Calc = new DoCalc((int x, int y) => x+y)
};
a.ShowMessage(a.Name);
int result = a.Calc(100, 200);
//来源:C/S框架网(www.csframework.com) QQ:1980854898
C# Code:
private delegate void DoSomething(object o);
private delegate int DoCalc(int a, int b);
//来源:C/S框架网(www.csframework.com) QQ:1980854898
private delegate void DoSomething(object o);
private delegate int DoCalc(int a, int b);
//来源:C/S框架网(www.csframework.com) QQ:1980854898
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网