"Object not set to an instance of an object" How do i check this?

  • Thread starter Thread starter aaa
  • Start date Start date
A

aaa

I know in VB we had IsObject ut how do I check an object to see if it exists
in sharp (without bombing the if)?
 
aaa said:
I know in VB we had IsObject ut how do I check an object to see if it exists
in sharp (without bombing the if)?

Test the expression for null:

if (x==null)
{
....
}
 
aaa said:
I know in VB we had IsObject ut how do I check an object to see if it exists
in sharp (without bombing the if)?

If an object variable doesn't reference a live object, it wll always be = null.
So if you want to use construct similar to vb, define a func:

bool IsObject(object ob)
{
return ob != null;
}

or just check inline using if ob == null
 

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

Back
Top