public static void Main()
{
dynamic obj = new ExpandoObject();
obj.Name = "Joe";
obj.Sub = (Func<int, int, int>)((int a, int b) => {
return a + b;
});
obj.SetAge = (Action<int>)((int age) => {
obj.Age = age;
});
obj.GetAge = (Func<int>)(() => {
return obj.Age;
});
Console.WriteLine(obj.Name);
Console.WriteLine(obj.Sub(1,2));
obj.SetAge(20);
Console.WriteLine(obj.GetAge());
}
執行結果:
Joe
3
20
沒有留言:
張貼留言