读书人

结构类型定义带参数构造函数有有关问题

发布时间: 2012-03-19 22:03:04 作者: rapoo

结构类型定义带参数构造函数有问题
public struct AddressBookEntry
{
public string Name;
public string MobilePhone;
public DateTime Birthday;

public AddressBookEntry(string name, string mobilePhone, string birthDay)
{
if (name ==null||mobilePhone == null || birthDay = null) throw new ArgumentException();
this.Name = name;
this.MobilePhone = mobilePhone;
this.Birthday = DateTime.Parse(birthDay);
}
}
红色部分带红色划线,提示"运算符||无法应用于bool和string类型的操作数"
求解

[解决办法]
birthDay == null
[解决办法]

if (name ==null||mobilePhone == null || birthDay = null) throw new ArgumentException();

少了个=

读书人网 >C#

热点推荐