public T ConvertParam<T>(Object obj)
{
return (T)obj;
}
为什么以上可以实现。
但是
object o = 5;
Int32 t = new Int32();
Int32 v = (t.GetType())o;
却不被通过?求知识,求解答,求科普。
{
return (T)obj;
}
为什么以上可以实现。
但是
object o = 5;
Int32 t = new Int32();
Int32 v = (t.GetType())o;
却不被通过?求知识,求解答,求科普。
Int32 t = new Int32();
Int32 v = (Int32)o;
Int32 u = Convert.ToInt32(o);
object w = Convert.ChangeType(o, typeof(Int32));你想用哪种。。
我的意思是为什么
object obj = 5;
Int32 n = new Int32();
n = (Int32)obj;
可以被通过
但是同为Int32类型动态获取的
n = (n.GetType())obj;
却不被通过?因为我强的类型是不确定的。
而我又不想用重载或者switch来做