This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 刚学DOT NET ,请教个问题1.
为什么C#语言要提供BOXING 和UNBOXING 功能,有什么特别的意义吗?
-bobo123(bobo);
2003-5-8
{70}
(#1177570@0)
-
This is because garbage collection. Boxing is the way that system keeps track how much memory need to be freed later.
-belsay(Belsay);
2003-5-8
(#1177620@0)
-
No, Boxing has nothing to do with garbage collection. Boxing enable a basic data type to have OO ability.
-miketany(MIKE老狼);
2003-5-8
(#1177638@0)
-
No, you are wrong. Boxing as nothing to do with OO. Boxing means that the system allocate space in heap and copy data from stack to managed memory in heap.
-belsay(Belsay);
2003-5-8
(#1177872@0)
-
他说的没错呀, 要不然MS这么别扭搞这么个BOXING为什么?
-decentboy(ROLIA第39);
2003-5-8
(#1177886@0)
-
数据在stack本来不需要garbage collection,微软硬要把它移到heap然后再回收,微软有病啊
-miketany(MIKE老狼);
2003-5-8
(#1178270@0)
-
sometimes using an object instead of a value type is necessary.
-agentkiller(等待好消息);
2003-5-8
(#1178311@0)
-
boxing--The conversion of a value type instance to an object, which implies that the instance will carry full type information at run time and will be allocated in the heap.The Microsoft intermediate language (MSIL) instruction set's box instruction converts a value type to an object by making a copy of the value type and embedding it in a newly allocated object.
-bbbb(鞭炮薄饼--灌水区里好);
2003-5-8
{193}
(#1178281@0)
-
Boxing and Unboxing | Unboxing Conversion
-bbbb(鞭炮薄饼--灌水区里好);
2003-5-8
{1514}
(#1178288@0)
-
2 centsboxing transfers a value type to reference type, Unboxing does the reverse.
Why needs reference type?
.NET class library needs reference type to pass parameters to methods. Such as:
For managed C++ code:
System.Console.WriteLine( " This is a test of output a int value, i={0}", __box(100) );
However, C# and VB.NET don't need explicitly Boxing on value types because they are converted automatically.
Hope helps.
-maple2000(新长征路上);
2003-5-8
{432}
(#1178345@0)
-
有没有visual studio .Net?能不能借来刻一下呢?谢谢!
-semaphore(一切都好 只欠烦恼);
2003-5-8
(#1178837@0)
-
CD-R does not work (you will have problem when you are installing). If you need the original CDs, please let me know. belsay20@yahoo.ca
-belsay(Belsay);
2003-5-8
(#1178974@0)