convert string to value type [closed]
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.
精彩评论