Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active January 30, 2016 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/2f52f41331903a630793 to your computer and use it in GitHub Desktop.
Save einarwh/2f52f41331903a630793 to your computer and use it in GitHub Desktop.
public sealed class PhoneNumber
{
private readonly string _;
public PhoneNumber(string s)
{
if (!ValidPhoneNumber(s))
{
throw new ArgumentException("Not a valid phone number");
}
_ = s;
}
public override bool Equals(object that)
{
return
that != null &&
this.GetType() == that.GetType() &&
this.ToString().Equals(that.ToString());
}
public override int GetHashCode()
{
return _.GetHashCode();
}
public override string ToString()
{
return _;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment