I expected the debugger display of variable a in the following code to be {11\n22} it however is {1122}:
class A
{
public string Text;
public override string ToString()
{
return this.Text;
}
}
A a = new A();
a.Text = "11\n22";
The debugger shows in the variables window:
display string of the object "{1122}" // why not "{11\n22}" ?
a.Text "11\n22"
a.ToString() "11\n22"
Tested with VS2012 and VS2010. I never realized this before. Anybody knows WHY the display string omits the \n character?
even adding [DebuggerDisplay("Text")] gives the same result.
Try to pin it and you will be see what you need.
It seems like Visual Studio is showing the Object.ToString() removing all the whitespaces.
But if you copy the text & paste it onto Notepad it shows the string with all the whitespaces.
Visual studio seems to designed/coded that way!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With