You can check it against the Empty constant on the string class, which
is an empty string. This is different from a null reference, which means
that you don't refer to any string at all. For the most part, they are
probably the same, but if you want to check against all cases, you can do
the following:
looking for empty or containing a space... this will work.
Also, if the list of characters you want to consider a "space" character is
outside the normal set, you can specify them in the String.Trim method that
I use in the second "if" statement below.
Hope this helps,
---- Nick
public bool IsMyStringEmpty(string Target)
{
if (Target.Length == 0)
return true;
else if (Target.Trim().Length == 0)
return true;
return false;
}
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.