首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-03-19 
结构类型定义带参数构造函数有问题public struct AddressBookEntry{public string Namepublic string Mob

结构类型定义带参数构造函数有问题
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();

少了个=

热点排行