日期:2014-05-18  浏览次数:20949 次

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

少了个=