StringBuilder.ToString() is adding ‘\’ characters in the beginning and ending of the string.
Why is this?
Before calling .ToString() the string doesn’t have the ‘\’ character.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are you thinking of these backslashes here?
If so, you are misreading the output: The backslashes are not actually in the string. They are only displayed here to make the representation valid according to C# syntax. If you were to output the string using
Console.WriteLine, for example, it would not have backslashes.To be fair, it is inconsistent. The debug view for the
StringBuilderdoesn’t have the backslashes, but the one for strings does.