I'm trying to print \"Hey\"
in the Console But when I run it It just print the "Hey"
without \
and when i put another \
in the beginning and \
in end it says theres an Error
Asked
Active
Viewed 100 times
0

Farhad Zamani
- 5,381
- 2
- 16
- 41

Eden Ichak
- 13
- 6
-
4`"\\\"Hey\"\\"` – Iłya Bursov Apr 14 '20 at 19:54
-
1Also you can use `@"\"` in order to print escape characters – panoskarajohn Apr 14 '20 at 19:56
-
1Alternatively `@"\""Hey""\"` where the backslashes don't need to be escaped, but now the double quotes do, with double double quotes. – juharr Apr 14 '20 at 20:09
1 Answers
4
You have to escape the "
as well as the \
. Both should be escaped with a backslash itself. Your final result should look something like:
Console.WriteLine("\\\"Hey\\\"");

Marian Klösler
- 620
- 8
- 22