0

How can I return "\" as text in the console?

Console.Write("\"); returns "Newline in constant" error. \ seems to be used to call a command. Hoe can i use it as text?

1st Nov 2016, 11:53 PM
Arthus James
Arthus James - avatar
2 Answers
+ 8
1. Its like what adonis stated. 2. If you wanted to declare a \ as a variable(string) and use it in the console, you cant. A variable must begin with a letter or an underscore, and can only contain letters, number or underscore. Even if you could, you would be using the wrong way, as the correct way should be Console.WriteLine(\); (No need for the inverted commas inside)
2nd Nov 2016, 5:09 AM
Wen Qin
Wen Qin - avatar
+ 2
You need to escape it with double "\\" Console.Write("\\");
2nd Nov 2016, 12:07 AM
Adonis
Adonis - avatar