快速问题。为什么下面两行都是有效的?
char x = '\"';
char y = '"';
如果 " 是一个特殊字符,那么第二行不应该被标记为不正确吗?
快速问题。为什么下面两行都是有效的?
char x = '\"';
char y = '"';
string x = "'";
string y = "\'";
Console.WriteLine(x == y); // Strings are equivalent
只有当纯值会产生歧义时,才需要使用转义序列。 转义序列是一种表达方式:编译器,请忽略其中一个字符以便于语法理解。将其视为纯值。
String s = """; //It would be unclear for the Compiler where the String ends and what is part of it. Hence Escape Sequencs are needed
char c = '"'; //It is clear where the Char starts and ends (the single Quotes).
char c = '''; //again unclear what of those is the Char. Escape Sequence needed.