ArrayList
類只能包含對象的引用,但在存儲值類型(如整數)時會發生什麼?ArrayList中的「存儲」值類型
string str = "Hello";
int i = 50;
ArrayList arraylist = new ArrayList();
arraylist.Add(str); // Makes perfectly sense:
// Reference to string-object (instance) "Hello" is added to
// index number 0
arraylist.Add(i); // What happens here? How can a reference point to a value
// type? Is the value type automatically converted to an
// object and thereafter added to the ArrayList?
的可能重複[如何在.NET 「拳擊」 的工作? ](http://stackoverflow.com/questions/5997398/how-does-boxing-work-in-net) –
不是真的 - 如果你已經知道這個問題的答案,你只會知道這兩者是相關的。 – mavnn
@Binary worrier - 這是相同的主題,但那麼你需要知道它是怎麼叫的.. –