I’ve always use String.IsNullOrEmpty to check for a empty string. It recently come to my attention that a ‘ ‘ count as not a empty string. For example,
Dim test As String = ' ' If String.IsNullOrEmpty(test) Then MessageBox.Show('Empty String') Else MessageBox.Show('Not Emtpy String') End If
It will show ‘Not Empty String’. So how do we check for ‘ ‘ or ‘ ‘ in a string?
edit: I wasn’t aware that ‘ ‘ count as character.
Try this method to check for blank strings. It is different from the Trim() versions in that it does not allocate a new string. It also uses a more expanded notion of whitespace.