String Manipulation - IsNullOrEmpty Method
- if (ourString == null)
- if (ourString == "")
- if (ourString.trim() == "")
- if (ourString == string.empty)
Luckily, Microsoft have came up with this great method "IsNullOrEmpty" which has something like this:
This is a great function thought it doesn't cover 100% of the cases. Lets say, for example, that I have this string: " ".
Now, according to Microsoft the IsNullOrEmpty method will return false.
Unfortunately, this is not a good result for us.
In order to fix this in our projects, we added this small method:
This will resolve our problem.
So now we can use:
.Net 4 Users:
For you guys Microsoft fixed that thing in the form of
CTO at ITweetLive.com