[DataContract]
[Serializable]
public class WSAccount
{
[DataMember]
public string AccountNumber { get; set; }
[DataMember]
public string Pin { get; set; }
}
[DataContract]
[Serializable]
public class WSUser
{
[DataMember]
public WSAccount wsAccount { get; set; }
[DataMember]
public bool IsValidUser { get; set; }
}
执行时出错
WSUser user = new WSUser();
user.wsAccount.AccountNumber = userNameresponse.account.ID;
但解决时
WSUser user = new WSUser();
user.wsAccount = new WSAccount();
user.wsAccount.AccountNumber = userNameresponse.account.ID;
我需要实例化子类 WSAccount 吗?