endyourif
New member
- Joined
- Feb 14, 2019
- Messages
- 1
- Programming Experience
- 10+
I'm really proud of this code readability improvement for the string.IsNullOrEmpty by creating a HasValue function
Indeed. WritingI would rather name the extension the same as the original though, since it is more accurate and I wouldn't have to think too much about what it actually means in different circumstances.
IsNotNullOrEmpty
and IsNotNullOrWhitespace
methods seems the better option. Using HasValue
precludes an equivalent for IsNullOrWhitespace
so you back yourself into a corner on that.str.Length
: string str = null;
bool x = str.Length > 0;
string str = null;
bool x = str?.Length > 0;