Absolutely. It's very easy to test:
using System;
using System.Text;
class Test
{
static void Main()
{
string x = "hello";
string y = "hello";
StringBuilder sb = new StringBuilder();
sb.Append(x);
string a = sb.ToString();
sb = new StringBuilder();
sb.Append(x);
string b = sb.ToString();
Console.WriteLine (object.ReferenceEquals(x, y));
Console.WriteLine (object.ReferenceEquals(x, a));
Console.WriteLine (object.ReferenceEquals(x, b));
Console.WriteLine (object.ReferenceEquals(a, b));
}
}
I did not check this however what you write in my
translation is that "string a" and "string b" are not strings however
references to a stringbuilder object, which holds strings, which are not
strings.
No, they're strings (or rather, string references).
StringBuilder.ToString() returns a string. The StringBuilder object
itself can be garbage collected after its use.
And in that case there is only one string and two objects which has
maybe a concationation of characters and is not a string in the meaning of
this however a method.
No, they're both strings. Otherwise they wouldn't be able to be held by
string variables, would they?
Other than the fact that the object x and y refer to are interned and
the objects a and b refer to aren't, there's basically no difference
between them.
I am not saying you are wrong, as you wrote (and what was committed by me)
is that the String is a kind of strange object.
It's not nearly as strange as some people think, to be honest.
The String looks for me as a legacy C method which is inherited in dotNet.
Nonsense - pretty much every development platform ever created has
strings.