Last active
January 30, 2016 12:35
-
-
Save einarwh/2f52f41331903a630793 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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