Click here to Skip to main content
15,921,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends i am new to .net i am often getting the error
" Object reference not set to an instance of an object." Can anyone explain me about that error with sample coding as a example . and how to rectify the error . please explain me with C# example
Posted
Comments
Bernhard Hiller 18-Sep-12 3:10am    
Actually the most important thing to do is: learn to use the debugger of Visual Studio!

 
Share this answer
 
Comments
[no name] 18-Sep-12 2:39am    
great one sir
Pandvi 18-Sep-12 3:05am    
If it sloves your problem, please mark it as answer!
Hello !

First try to use this link: http://stackoverflow.com/questions/8206810/object-reference-not-set-to-an-instance-of-an-object[^] for a quick reference.

Generally this exception occur when u didn't check any condition for null.Suppose u want some data to display on a page and u didn't check that this data is empty.

ex- if(txtname.text != null)
{
some code here........
}

in this case it doesn't give an exception.If u didn't check for null values then it gives an error.

I think u got my point.if not please let me know i will explain u in details.

Thanks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900