Invalid output with inherit class
问题 I have 2 classes [DataContract, KnownType(typeof(B))] public class A { [DataMember] public string prop1 { get; set; } [DataMember] public string prop2 { get; set; } [DataMember] public string prop3 { get; set; } } [DataContract] public class B : A { [DataMember] public string prop4 { get; set; } } and the following method: List<B> BList = new List<B>(); BList = new List<B>() { new B() { prop1 = "1", prop2 = "2", prop3 = "3", prop4 = "4" } }; List<A> AList = BList.Cast<A>().ToList();