Drawing a literal string in windows

I have a line below

"!\"#$%\"&'\\(%\\)" 

I process each character of this string individually and I get '\\\' before '(' or ')'

But I do not want to get '\\\' before '(' .

I tried replacing it or removing it, but it does not work. How to do it?

Code here: input.Replace('\\(', '(');

+4
source share
1 answer

The characters / and " are special characters in C #, so if you want to print them you need to use escape sequences. Enter \ before each \ and " as follows:

Code example:

 static void Main(string[] args) { const string s = "! \\ \" # $ % \\ \" & ' \\ \\ ( % \\ \\ )"; foreach (char c in s) { Console.WriteLine(c); Console.Read(); } } 

In this console example, you will get each character every time you press the enter key. By the way, added spaces are important for printing each character. If you remove spaces, characters will be printed in pairs.

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1487462/