V
VMI
How can I validate a null string or an empty string in the same IF
statement?
If I use this:
if (myString.Trim().Length <= 0 || myString == null)
{
//do stuff
}
I'll get a run-time error because I can't trim (or get the length) of a Null
value. But I don't want to have two IFs (one that validates null and one
that validates an empty string). And I don't want to convert the null value
into a something that can be validated.
Any solution?
Thanks.
statement?
If I use this:
if (myString.Trim().Length <= 0 || myString == null)
{
//do stuff
}
I'll get a run-time error because I can't trim (or get the length) of a Null
value. But I don't want to have two IFs (one that validates null and one
that validates an empty string). And I don't want to convert the null value
into a something that can be validated.
Any solution?
Thanks.