문제

What I understand unboxing is when I take a object and unbox it to valuetype like the MSDN example:

int i = 123;
object o = i;  
o = 123;
i = (int)o;  // unboxing

So I just was thinking, can a string be unboxed? I think, No it can't because there is no valuetype that can represent a string. Am I right?

도움이 되었습니까?

해결책

You're right. A string can't be unboxed because only value types are subject to boxing and unboxing; a string is a reference type.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top