Search code examples
c#c#-4.0verbatim-string

Reading a string from a form as a verbatim string, \\ showing instead of \


I have the following property:

public string InstanceName
{
    get
    {
        return cbServerInstanceName.Text;
    }
}

where the input for

cbServerInstanceName.Text = "ServerName\ PcName"

This is showing up as

 "ServerName\\ PcName" 

I tried using the string.replace but couldnt get it to work.

Any ideas?


Solution

  • When you are using C# and looking at strings in the debugger, it will escape certain characters and \ is one of them; it will show in the debugger as \\ but at runtime and not viewed in the debugger, it will be converted to a single \