开发者

convert string to value type [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

How to convert string ref type to v开发者_Go百科alue type..


There is no such thing as a string value type in C#.

The System.String class is indeed a reference type.

Tell us what you are trying to accomplish, and we might be able to suggest alternative solutions.


Since string is constant (every mutation results in a new instance), there is no need to handle strings as value types. The actually behave the same as value types. Even comparison operations (Equals and ==) are based on the strings content, not on the reference.


You can only convert boxed values to value types. String is reference type and it can't become value type because there's no such thing as boxing for reference types.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜