Yes, it is surely a reference type. You can see it if you take the object
System.Type stringType = string.GetType()
and inspect it.
But the implementation of this type is pretty unusual. Basically, it simulates
value-type semantic. First of all, the semantic content of the string is
immutable. There is no a way to modify string content. All string functions modifying content actually create a brand-new string object and return it. Besides, it is based on the
interning mechanism and
intern pool. Please see:
http://msdn.microsoft.com/en-us/library/system.string.intern(v=vs.110).aspx[
^],
http://msdn.microsoft.com/en-us/library/system.string.isinterned(v=vs.110).aspx[
^],
http://en.wikipedia.org/wiki/String_interning[
^].
And, finally, your question about equality is way too trivial. You can create the same effect on your own types. You need to override
System.Object.Equals
method, which will also require overriding of
System.Object.GetHashCode
(the reasons for enforcing this rule are pretty obvious, related to the use of the object in collections based on
buckets, the mechanism based on hash code):
http://msdn.microsoft.com/en-us/library/system.object%28v=vs.110%29.aspx[
^].
Also, you can define your custom == and != operators. This way, you can define your own equivalence criteria, not referential but semantic.
—SA