tags:

views:

100

answers:

3

Can someone explain me the behaviour of the following line in VB

Return Not (s Is Nothing)

I am looking to translate this in C# and i am not sure about those negation and do not understand the conditions.

+3  A: 
return s != null;
Jimmy
thanks for the quick answer. I understand those negation better now.
DrDro
+5  A: 

In C# this would be

return s != null

A more direct transaltion is

return !(s == null)

but that would be odd looking in C# so the original translation is prefered.

Mike Two
I also find the fact that it returns a boolean confusing. I would have expected it to mean "return s if it isn't null" instead of "return is s null or not"
DrDro
DrDro, I can see how you might see it that way, but what would it return if s is null? It has to return something. If it would just return null if s was null then that just be `return s`
Mike Two
+4  A: 

Just FYI, in “idiomatic” VB, this would rather be written as:

Return s IsNot Nothing
Konrad Rudolph
Sounds more natural, anyway :)
OregonGhost
Null is Nothing in VB
Julien Poulin
@Julien: Duh. Of course.
Konrad Rudolph