Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我所理解的拆箱是当我将一个对象拆箱为valuetype时,例如 MSDN 示例:
int i = 123; object o = i; o = 123; i = (int)o; // unboxing
所以我只是在想,一个字符串可以拆箱吗?我认为,不,它不能,因为没有可以表示字符串的值类型。我对吗?
你是对的。一个字符串不能被拆箱,因为只有值类型需要装箱和拆箱;字符串是引用类型。