hi all, im trying to do a properties validation if a value for my property for example userName is null then i will return an empty string instead of a null value
but if i have lots of properties for an object, do we have to do it like below validation (redundancy), im wondering if this is a good way, can anyone help to advise? thank you so much in advance..
private string _userName; public string userName { get { return _userName; } set { if (string.IsNullOrEmpty(value)) _userName = string.Empty; else _userName = value; } }
private string _userName; public string userName { get { return _userName; } set { if (string.IsNullOrEmpty(value)) _userName = string.Empty; else _userName = value; } }