利用dynamic动态创建对象

dynamic MyDynamic = new System.Dynamic.ExpandoObject();
MyDynamic.A = "A";
MyDynamic.B = "B";
MyDynamic.C = "C";
MyDynamic.Number = 12;
MyDynamic.MyMethod = new Func<int>(() =>
{
    return 55;
});
Console.WriteLine(MyDynamic.MyMethod());
Console.WriteLine(MyDynamic.A);

转载于:https://www.cnblogs.com/jizhiqiliao/p/10138109.html

你可能感兴趣的:(利用dynamic动态创建对象)