有一个对象的类型,以及转化为object的对象,如何得到真正类型的对象例如Point point = new Point(10,10);
Type type = typeof(Point);
object obj = new object();
obj = (object)point;
能取得的只有type和obj,能不能得到Point的实例呢
Type type = typeof(Point);
object obj = new object();
obj = (object)point;
能取得的只有type和obj,能不能得到Point的实例呢
object point = new Point(10,20);
string str=point.GetType().GetProperty("X").GetValue(point, null).ToString();
Point point = new Point(10, 10);
Type type = typeof(Point);
object obj = new object();
obj = (object)point;
object o = Activator.CreateInstance(obj.GetType(), new object[] { 10, 10 });
是object啊,但它就是Point类的一个实例啊
你想要达到什么目的?
[code=C#] Point point = new Point(10, 10);
object obj = (object)point;
Point p = (Point)obj;
code]
Activator.CreateInstance(typeof(Point));
PS:你现在是想通过反射来实现深拷贝么?你先把思路写一下。