首页 > 解决方案 > 错误“只有赋值、调用、递增、递减、等待和新对象表达式可以用作语句”

问题描述

错误 CS0201 只有赋值、调用、递增、递减、等待和新对象表达式可以用作语句

代码=

private void addIntel(string label, string kind, string detail, string insertText)
        {
            "\"" + label + "\"";
            "\"" + kind + "\"";
            "\"" + detail + "\"";
            "\"" + insertText + "\"";
            this.webBrowser1.Document.InvokeScript("AddIntellisense", new object[]
            {
                label,
                kind,
                detail,
                insertText
            });
        }

标签: c#

解决方案


"\"" + label + "\"";是一个不调用任何东西、不分配任何东西并且不创建任何新对象的语句。这就是错误的全部内容。我猜你想要做的是在你的值周围添加引号,但这样做你还需要将结果分配回你的变量,就像这样。

label = "\"" + label + "\"";
kind = "\"" + kind + "\"";
detail = "\"" + detail + "\"";
insertText = "\"" + insertText + "\"";

推荐阅读