I am starting to learn C # and I donβt understand why regular string literals (ie " " ) cannot contain newline alphabetic characters. (I'm not talking about the escape sequence \n ). I know that for multi-line strings you should use literal string literals (i.e. @" " ), but why?


I have not seen this explicitly indicate that you cannot use them in regular strings. Moreover, except when he mentioned in passing that I can use literal strings for this, everything I read seems to suggest that literals with a newline character will be allowed in ordinary string literals.
Starting in Visual C # 2010 and Code: Generating Multiline String Literals (Visual C #) show examples of verbal multiline strings without any further explanation.
Learning C # 3.0 says the following:
In C #, spaces, tabs, and newlines are considered spaces ... Instances are usually ignored in C # statements .... An exception to this rule is that a space inside a line is considered literal; he is not ignored.
So is this literal? This is what I also expected, but it is not. It even includes this tip:
Tip
Visual Basic programmers note: in C #, the end of a line does not really matter. Statements end with a semicolon, not newlines. There is no line continuation character because there is no need.
(I understand that this is about outside the lines, but why does the end of the line have special parsing inside the line if it is not outside the line?)
I finally found the path to string (C # Reference) , I still do not understand:
String literals can contain any character literal. Evacuation sequences are included. The following example uses the escape sequence \\ for the backslash, \u0066 for the letter f, and \n for the new line.
It says that escape sequences can be used, but he does not say that they should be used. Are lined newline characters not included in "any character literal"? If I have a line that contains an alphabetic tab character instead of its escape sequence \t , there is no error. But if I have a literal newline, I get an error. I even changed the line ending of the file from \r\n to \n or \r without effect.
Obviously, I can conclude from examples and from Visual Studio errors that a verbatim string is required if it contains an alphanumeric newline character, but everything I read suggests that this should not be. Why is the difference?