August 03, 2006

object reference not set to an instance of an object

This exception occur when your are try to access a property,field of a object which
is not intialized to some valid value. Means it is null

or a dynamic object which does not exists

For example:

object a=null;

a.ToString();

This will throw exception "object reference not set to an instance of an object"

Regards
Raj

3 comments:

Anonymous said...

Thanx for you reply. I often find this error. Thanx Sir

whiskypriest said...

is it C++ (thats all my knowledge permits me to comment)

Dot Net Guy said...

No this is c#. Actually it's most of syntax is from c++. I thought that's why it seeeming u like C++.