A only needs to be boxed if it's going to be used as an object. If you are
converting from a long to an int, it's a simple cast (in C#), and in fact
there are specific IL opcodes for those cases (conv.* opcodes).
Boxing takes a value type, then sticks it inside an object (hence the term
boxing). This is needed if you do something that takes an object parameter,
and you're passing a valuetype. The boxing happens automatically (for C#).
When you take it back out of an object, you unbox. This requires you do a
cast, for instance int i = (int)myArrayList[0]; (C#).
So, you generally don't need to worry about what to do; the compiler will do
it for you or give you an error if it's an invalid cast and it can detect
it.
-mike
MVP
"Michael Giagnocavo [MVP]" <mggUNSPAM@Atrevido.net> wrote in message
> A only needs to be boxed if it's going to be used as an object. If you are
> converting from a long to an int, it's a simple cast (in C#), and in fact
> there are specific IL opcodes for those cases (conv.* opcodes).
Thank you, now it's more clear.
I'm talking about IL, not C#, so I would know how things going on in there
:)
See you
--
Math Parser : http://www.neodatatype.net
Sito Comune : http://www.it-lang-vb.net
Zanna - 30 Nov 2003 09:48 GMT
"Zanna" <znt.fabio@virgilio.it> wrote in message
news:bqcc2e$1vsm0c$1@ID-184808.news.uni-
> I'm talking about IL, not C#, so I would know how things going on in there
Another question: with IL, how can I do a conv. from... let's say from Int32
to System.Drawing.Color?
Thanks again
--
Math Parser : http://www.neodatatype.net
Mattias Sj?gren - 30 Nov 2003 15:57 GMT
>Another question: with IL, how can I do a conv. from... let's say from Int32
>to System.Drawing.Color?
The conv opcodes are only for primitive types. For Int32 -> Color
you'd call Color::FromArgb or use the ColorTranslator class.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Michael Giagnocavo [MVP] - 30 Nov 2003 18:40 GMT
To learn easily, write samples in C#, then compile and ILDASM to see exactly
what's going on.
-mike
MVP
> "Michael Giagnocavo [MVP]" <mggUNSPAM@Atrevido.net> wrote in message
>
[quoted text clipped - 12 lines]
> Math Parser : http://www.neodatatype.net
> Sito Comune : http://www.it-lang-vb.net