On MSDN, I can read that \'this is an escape sequence for 'char. However, I can use it in a string without an escape sequence as follows:
\'
'
Console.WriteLine("Press 'X' ");
How is this possible?
But how could you write it like that char?
char
char c = '\'';
char(literal of one character) is a different data type than string(verbose literal).
string
In C # a is chardeclared as:
var c = 'c';
whereas a is stringdeclared as:
var s = "asdf";
, (') , char, :
var c = '\'';
\'screening is required for char literals. The reason is that it 'can be interpreted as an alphabetic boundary symbol. For strings, this is pointless because there is nothing to confuse. In stringsturn \"makes sense.
strings
\"
It says that you need to exit 'for a char data type.
char c = '''; // compiler throws error char c = '\''; // valid