Wednesday, August 28, 2013

C# : String with spaces is not null or empty

Came across an interesting case.

I was checking a text field with


and I noticed that if you enter spaces, it is neither null or empty!

Mr. Google out of bed bright and early and:

String.IsNullOrEmpty() Check for Space

The solution is the "IsNullOrWhiteSpace(string value)" one.


No comments: