Connecting Tech Pros Worldwide Forums | Help | Site Map

Null Reference Exception

john sutor
Guest
 
Posts: n/a
#1: Nov 16 '05
Can someone tell me the difference between the NullReferenceException and
the NullPointerException?
Also, please explain what they are.


Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#2: Nov 16 '05

re: Null Reference Exception


john sutor <john_sutor@NOSPAM> wrote:[color=blue]
> Can someone tell me the difference between the NullReferenceException and
> the NullPointerException?
> Also, please explain what they are.[/color]

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!

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Closed Thread