嗨,我有一个从 http 响应返回的流。我已将其反序列化为 Object(obj),并希望将 obj 的类型检查为 MyObject 或 string 或 double。是程序错误还是我的概念错误。请帮忙。
DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(Object));
Object Obj = obj.ReadObject(_stream) as Object;
Product p = new Product();
List<string> ls = new List<string>();
List<DisplayProduct> displs = new List<DisplayProduct>();
if (Obj.Equals(p))
Console.WriteLine("PRODUCT");
else if (Obj.Equals(ls))
Console.WriteLine("LIST OF STRING");
else
Console.WriteLine("DISPLAY PRODUCT LIST");