Null Reference Exception

  • Thread starter Thread starter john sutor
  • Start date Start date
J

john sutor

Can someone tell me the difference between the NullReferenceException and
the NullPointerException?
Also, please explain what they are.
 
john sutor said:
Can someone tell me the difference between the NullReferenceException and
the NullPointerException?
Also, please explain what they are.

NullPointerException is a Java exception - you may see it in J#, but
not otherwise (as far as I know).

NullReferenceException is the normal .NET one. Basically it indicates
that you're trying to "dereference" null. For instance:

string x = null;
int i = x.Length; // Nope - the value of x is null, not a reference
// to a valid string object!
 
Back
Top