JsonConfig
JsonConfig copied to clipboard
Reading Strings with "\" in them
I have a db connection string in my config file:
Connection: "localhost\sqlexpress"
but when I debug. in code the variable is " localhostsqlexpress" (no "" )
and if put two "" then both of them appear in the variable?
is there a special way I need to read the string?
To read the string you need to escape "".
Your config file should look similar to this:
{ "Connection" : "localhost\\sqlexpress" }
The Debug breakpoint will display "localhost\\sqlexpress"
. However, try printing it to console. It should print "localhost\sqlexpress"
.