programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Saturday, October 11, 2014 NullReferenceException and how fix it

What is a “NullReferenceException” and how fix it in

The runtime throwing a “NullReferenceException” always means the same thing. You are trying to use a reference to an object which isn't initialized. It means your code used an object reference variable (actual object instance) that was set to null.

When “NullReferenceException” occurs:

When we declare a variable but not initialized the value to declared variable.
Int a; If this case some time it’s possible that here occurs NullReferenceException.

Example of NullReferenceException:

Int a;
Response.wright(a);   //Exception can occur here.

How to prevent by NullReferenceException:

This means the reference points to null, on which you cannot access members.

The simplest case:

String foo = null;

This will throw a NullReferenceException at the second line, because you can't call the instance method ToUpper() on a string reference pointing to null.

Other Example:

Checkboxlist control related old post :

No comments:

Post a Comment