Re: is null allowed in C#?
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 08/25/04
- Next message: Jon Skeet [C# MVP]: "Re: why Generics ?"
- Previous message: Gidi: "Re: Transfering DataSet to the dataBase"
- In reply to: Fei Li: "is null allowed in C#?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 25 Aug 2004 07:09:02 +0100
Fei Li <FeiLi@discussions.microsoft.com> wrote:
> Is null value for a class instance allowed in C#? for example:
> MyClass obj = null;
obj is a variable, not a class instance. null is effectively something
saying, "This value isn't a reference to a class instance at all. It's
a reference to no object."
> If Not, how to initiate an instance with value 0?
What do you mean "with value 0"?
> How to detect if an instance is "newed" ?
If a reference is non-null, it's a reference to an instance.
> And how to pass a null value to a class constructor
> whch has a object paramer can be 0?
Just pass null.
> In general, how C# handle a pointer with value 0;
null is a special reference. You can possibly think of it as a pointer
with value 0, but it's better not to think in those terms - just think
of it as a reference meaning "No object".
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Jon Skeet [C# MVP]: "Re: why Generics ?"
- Previous message: Gidi: "Re: Transfering DataSet to the dataBase"
- In reply to: Fei Li: "is null allowed in C#?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|