In C#, why is String a reference type that behaves like a value type?

后端 未结 12 2340
抹茶落季
抹茶落季 2020-11-22 02:04

A String is a reference type even though it has most of the characteristics of a value type such as being immutable and having == overloaded to compare the text rather than

12条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 02:38

    How can you tell string is a reference type? I'm not sure that it matters how it is implemented. Strings in C# are immutable precisely so that you don't have to worry about this issue.

提交回复
热议问题