"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
 
Back
Top