'Override implicit conversion for existing types
In my code I am handling emails sometimes as string string emailA = "[email protected]". But most of the time an actual MailAddress object is passed around and handled. My question is can I implement an implicit conversion from string to MailAddress if I have no control over either type?
If this was an object implemented by me i could use this: public static implicit operator MailAddress(string email) => new MailAddress(email);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
