Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape sequence with "\" symbol

Tags:

c#

i have one string, and i assign the value like,

string str="admin" + @"\" + "user";

The output of the "str" value comes as

"admin\\user"

. But i need "str" value as

"admin\user"

. That means i need single "\" symbol instead of "\\" within the string values. How can i get this?

like image 346
Manikandan Sethuraju Avatar asked Jul 30 '26 07:07

Manikandan Sethuraju


1 Answers

The output of the "str" value comes as "admin\\user"

No, it really doesn't. The string itself will just have a single backslash.

If you look at it in the debugger you will see the escaping, but that doesn't mean it's part of the string. It's just the debugger representation. Print it to the console, or log etc to see the real value.

like image 157
Jon Skeet Avatar answered Jul 31 '26 20:07

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!