【问题标题】:C# newline constant error upon trying to compile尝试编译时出现 C# 换行常量错误
【发布时间】:2010-09-11 05:29:10
【问题描述】:

由于某种原因,当我尝试使用 Visual Studio 命令提示符将我的 .cs 文件编译为 .dll 时,由于某种原因尝试编译时,我得到了 new line constant error

不喜欢+ feet"后面的分号。

知道为什么吗?

这是我的代码:

/* A simple C# class! */

public class Tree
{
    public int height = 0;

    public void Grow(int h)
    {
        height += h;
    }

    public string Message()
    {
        return "The height of tree1 is:<br/>" + tree1.height + feet";
    }    
}

【问题讨论】:

    标签: c# compiler-construction compilation


    【解决方案1】:

    脚前需要另一个 "

    public string Message()
    {
        return "The height of tree1 is:<br/>" + tree1.height + "feet";
    }
    

    编辑:实际上是在抱怨最后一个以 "; 开头的字符串没有终止。

    【讨论】:

    • 嘿,谢谢,哇,我不敢相信我忘记了这一点。在我发布的其他代码示例中,我忘记了它,但没有人提到它,所以我认为它没问题 :) 谢谢!
    • 语法高亮对于发现这类错误很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-22
    • 2013-03-04
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 2017-03-20
    • 1970-01-01
    相关资源
    最近更新 更多