c# - 错误“只有赋值、调用、递增、递减、等待和新对象表达式可以用作语句”
问题描述
错误 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
});
}
解决方案
这"\"" + label + "\"";
是一个不调用任何东西、不分配任何东西并且不创建任何新对象的语句。这就是错误的全部内容。我猜你想要做的是在你的值周围添加引号,但这样做你还需要将结果分配回你的变量,就像这样。
label = "\"" + label + "\"";
kind = "\"" + kind + "\"";
detail = "\"" + detail + "\"";
insertText = "\"" + insertText + "\"";
推荐阅读
- oracle - 当某些值为空时比较Oracle中的日期?
- spring - Spring MVC项目中的数据源没有形成Bean
- python - 无法交换python列表中的多个元素
- javascript - 从非回调函数中获取事件参数(普通函数调用)
- php - 如何编写一个雄辩的查询,将这 2 个查询连接、合并或联合为 1?
- node.js - 在分配唯一端口的同时扩展 nodejs 应用程序
- azure-devops - 当代码覆盖率低于某个参数时,可以运行构建管道失败
- javascript - 如何让 discord.js 从文件中选择随机图像
- gerrit - 全新安装后未启动 Gerrit 代码审查(前提)
- javascript - APK 和 Expo Client android 应用不同