Re: Box and UnBoxing
From: Shayne Wissler (thalesNOSPAM000_at_yahoo.com)
Date: 11/24/04
- Next message: Mikito Harakiri: "Re: Generating SQL"
- Previous message: Vladimir Levin: "Re: Thought Before Action."
- In reply to: Robert Klemme: "Re: Box and UnBoxing"
- Next in thread: Robert Klemme: "Re: Box and UnBoxing"
- Reply: Robert Klemme: "Re: Box and UnBoxing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 24 Nov 2004 17:01:55 GMT
"Robert Klemme" <bob.news@gmx.net> wrote in message
news:30joq7F31ihdfU1@uni-berlin.de...
>
> "Vijay singh" <vij_singh@hotmail.com> schrieb im Newsbeitrag
> news:90f0abe8.0411240714.42d67d23@posting.google.com...
>> Isn't Box /unboxing in C# similar to casting or something else?
>
> I assume it's the same as in Java and then it's not similar to casting.
> Boxing creates a new instance of a different class, while casting just
> tries to access the same instance as another type.
>
> In Java:
>
> # Boxing
> Object o = new Integer( 5 );
>
> # Casting
> Number n = (Number) o;
>
> I assume it's similar in C# as that has the distinction between Objects
> and POD's, too.
In C/C++, casting primitives creates a new instance of a different type.
With user-defined type conversion, new objects are created.
I think Java is a bad language to compare this feature with, since with Java
you only have pointers to objects not objects. C++'s semantics are closer to
C# on this point.
Shayne Wissler
http://www.ouraysoftware.com
- Next message: Mikito Harakiri: "Re: Generating SQL"
- Previous message: Vladimir Levin: "Re: Thought Before Action."
- In reply to: Robert Klemme: "Re: Box and UnBoxing"
- Next in thread: Robert Klemme: "Re: Box and UnBoxing"
- Reply: Robert Klemme: "Re: Box and UnBoxing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|