First of all, you can't overload the != directly, only == (you get !=
from the == operation).  Second, I would say:

if (xyz != null)

Or

if (!(xys == null))

Both are equivalent since you can only overload the == operator (of
course the second one is just plain ugly I wouldn't really use it except
to show this point).

Thanks,

Shawn Wildermuth
[EMAIL PROTECTED]

> -----Original Message-----
> From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> On Behalf Of David Ferguson
> Sent: Saturday, May 04, 2002 3:06 PM
> To: [EMAIL PROTECTED]
> Subject: [DOTNET] What is the correct way to test for Is
> Nothing in C#?
>
>
> In VB I would say...
>
>     if (Not xyz Is Nothing)
>
> In C# I am inclined to say...
>
>     if (xyz != null)
>
> but I am concerned that an object might override operator !=.
>  What is the recommended way to do this test in C#?
>
> Thanks...David
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to