After two years of C#, I'm now back to VB.net because of my current job. In C#, I can do a short hand testing for null or false value on a string variable like this:
if(!String.IsNullOrEmpty(blah))
{
...code goes here
}
however I'm a little confused about how to do this in VB.net.
if Not String.IsNullOrEmpty(blah) then
...code goes here
end if
Does the above statement mean if the string is not null or empty? Is the Not
keyword operate like the C#'s !
operator?
In the context you show, the VB Not
keyword is indeed the equivalent of the C# !
operator. But note that the VB Not
keyword is actually overloaded to represent two C# equivalents:
!
~
For example, the following two lines are equivalent:
useThis &= ~doNotUse;
useThis = useThis And (Not doNotUse)
Yes they are the same
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With