Object对象如何转换为已知类型的对象
请教一下,
var obj =new {name="jack" ,age=11};
mytype obj2=(mytype)obj;
报错,转不成功,是为什么? mytype的字段与obj的字段完全相同,也是name和age ,并且类型也是相同的。
错误具体大意为:
无法将类型为“<>f__AnonymousType2`11[ System.Int32,
System.Int32,
System.Int32,
System.String,
System.String,
System.Int32,
System.Int32,
System.Int32,
System.String,
System.String,
System.String]”的对象强制转换为类型“Model.NorthAmericaStorehouse”。