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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Santhakumar MunuswamyRank #128 · 17.3K reputationPosted Apr 7, 2015, 10:45 AM EDT
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
}
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Apr 7, 2015, 4:12 PM EDT
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
Arunava BhattacharjeeRank #635 · 3.8K reputationPosted Apr 7, 2015, 7:53 PM EDT
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.
Gowtham RajamanickamRank #57 · 29K reputationPosted Apr 7, 2015, 8:30 PM EDT
Gowtham RajamanickamRank #57 · 29K reputationPosted Apr 7, 2015, 8:30 PM EDT