Dear Sir/Mam,
Please have a look in my Name class below
which is intended to Use Like Built in sealed String Class : -
public class NameField { readonly string _value; public NameField(string value) { this._value = value; } public static implicit operator string(NameField d) { if (d._value.Length > 5) throw new System.Exception(""); return d._value; } public static implicit operator NameField(string d) { return new NameField(d); } }
now we can set values like:-
NameField myName="Sanjeeb Kumar Chaudhary"
Now I want to Show Conditional Compile Time error like below:-
Thus, kindly suggest how to do so ?