Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace EfAndCpf
- {
- public class Email
- {
- public string EmailValue { get; private set; }
- private Email()
- {
- }
- private Email(string value)
- {
- EmailValue = value;
- }
- public static implicit operator Email(string value)
- => Parse(value);
- public static implicit operator string(Email email)
- => email.EmailValue;
- public static Email Parse(string value)
- {
- // ... validations here
- // throwing exceptions if something goes wrong.
- return new Email(value);
- }
- public bool IsEmpty => EmailValue == null;
- public override string ToString()
- => EmailValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement