dynamic:
void Main()
{
var b="2";
dynamic a="2";
if(a.GetType()==typeof(int))b+=a;
if(a.GetType()==typeof(string))b+=a;
Console.WriteLine (b);
Console.WriteLine (GetName(1));
Console.WriteLine (GetName(2));
}
// Define other methods and classes here
dynamic GetName(int a){
dynamic ret;
if(a==1)ret=2;
else ret="b";
return ret;
}
c# dynamic,maybe I should say it is just some shortcut for "Object", box and unbox, without the cast
原文:http://www.cnblogs.com/hualiu0/p/5036137.html