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; }
时间: 2024-11-05 18:42:47