What Is Null Exception.
what is null exception an how to control null exception in asp page?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gowtham RajamanickamPosted Apr 8, 2015, 12:30 AM
Gowtham RajamanickamPosted Apr 8, 2015, 12:30 AM
Arunava BhattacharjeePosted Apr 7, 2015, 11:53 PM
Null exception usually occurs if you have wrong logic in the code. Sometimes, it is useful to leave the code as it is while developing the application. Otherwise, please do a null check before performing an operation on an object which you think it might become null.
if(obj!=null)
{
//perfrom operation
obj.DoSomeStuff();
}
else always put your potential code inside a try..catch..finally block and log a meaningful exception.
Please mark the answer as accepted, if you think it helped you.
Pankaj Kumar ChoudharyPosted Apr 7, 2015, 8:12 PM
NullReferenceException is common. It indicates that you are trying to access member fields, or function types, on an object reference that points to null. It indicates a flaw in the code.
For better understanding you can refer below links:
http://csharp.net-informations.com/string/string-null-cs.htm
http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it
Santhakumar MunuswamyPosted Apr 7, 2015, 2:45 PM
Try this below link
http://www.dotnetperls.com/nullreferenceexception
Ex.
if(StringVariable!=null)
{
// do something here
}
Instead of that you can use below
if(!String.IsNullOrEmty("StringVariable))
{
// do something here
}