问题描述
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1009: Unrecognized escape sequence
Source Error:
Line 42:
Line 43: public override void Execute() {
Line 44: WriteLiteral("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Line 45: "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Line 46: "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9d389ed9\2c615f86\App_Web_index.cshtml.c114ca27.wbkbq-st.0.cs Line: 44
有人检查昨天的项目是否正常,但今天不工作.它可以毫无问题地编译和构建,但是不起作用.
Someone check that yesterday project work fine but today it's not work. it compile and build without any trouble but doesn't work.
推荐答案
第44行:您有81个反斜杠.在第45和46行上,每个都有80.当在字符串文字中使用时,反斜杠字符用作转义"字符来表示诸如换行符和制表符之类的内容.如果您确实希望在字符串中使用反斜杠,则需要为每个所需的反斜杠指定2个连续的反斜杠.由于第44行上的反斜杠数量奇数,因此会出现错误.
On line 44: you have 81 backslashes. On lines 45 and 46 you have 80 each. When used in a string literal, the backslash character is used as an "escape" character to indicate things like new-lines and tabs. If you actually want the backslash in your string, you need to specify 2 consecutive backslashes for each backslash desired. Since you have an odd number of backslashes on line 44, you are getting the error.
如果您确实想要这么多的反斜杠,可以在C#中通过在字符串文字前加上@来禁用转义符,如下所示:
If you really want that many backslashes, you can disable the escape character in C# by preceding the string literal with an @ like this:
WriteLiteral(@"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
+ @"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
+ @"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
或者,您可以从第44行中删除一个反斜杠.
Alternatively, you can delete one of the backslashes from line 44.
这篇关于编译器错误消息:CS1009:无法识别的转义序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!