Check to see if object instance exists

L

Larry

Thanks in advance.
what is the C# equivalent of the VB.net IsNothing(object) function?
just trying to check to see if an object instance already exists.
does someone have an example?
 
J

Jon Skeet [C# MVP]

Larry said:
Thanks in advance.
what is the C# equivalent of the VB.net IsNothing(object) function?
just trying to check to see if an object instance already exists.
does someone have an example?

Well, if what you mean is that you want to see if the value of a
variable refers to an object or not, you want:

if (x==null)
 
F

Freiddy

Thanks in advance.
what is the C# equivalent of the VB.net IsNothing(object) function?
just trying to check to see if an object instance already exists.
does someone have an example?

*** Sent via Developersdexhttp://www.developersdex.com***

It's quite easy: you just compare to "null"

object someobject;
someobject = someMethod();
if (someobject == null)
{
// if it's null, then what?
}

Does that solve your problems?

--Freiddy
http://fei.yuanbw.googlepages.com/
 

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.

Ask a Question

Top