【发布时间】:2012-01-10 15:07:37
【问题描述】:
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?
【问题讨论】:
-
不是真的 - 如果你已经知道这个问题的答案,你只会知道这两者是相关的。
-
@Binary worrier - 这是同一个主题,但你需要知道它是如何被调用的......
-
@mavnn 这并不意味着它们不是同一个东西,虽然;p 一点重复(尤其是不同的标题等)是健康的。