我的网络服务中有这两个类:
[DataContract]
public class AllFile
{
[DataMember(IsRequired = true)]
public virtual string base64Data { get; set; }
}
[DataContract]
public class UploadFile : AllFile
{
[DataMember(IsRequired = true)]
public string data;
[DataMember(IsRequired = true)]
public override string base64Data { get { return data; } set { data = value; } }
}
ServiceReference.UploadFile obj = new ServiceReference.UploadFile();
obj.base64Data = "something";
AllFile file = (UploadFile)obj;
但是,它告诉我 file.base64Data 为空。为什么?我以为我已经覆盖了子类。