使用dynamic 类型动态调用方法
时间:2010-09-03 来源:Navi
class Program
{
static void Main(string[] args)
{
dynamic d = Activator.CreateInstance(typeof(DemoType));
object o = d.ToString();
Console.WriteLine(o);
Console.WriteLine(d.Value);
}
}
class DemoType
{
public override string ToString()
{
return "Hello World";
}
public int Value
{
get
{
return 100;
}
}
}
相关阅读 更多 +