C#-只能将赋值、调用、递增、递减和新对象表达式用作语句
我在尝试运行此语句时收到上述错误:C#-只能将赋值、调用、递增、递减和新对象表达式用作语句,c#,C#,我在尝试运行此语句时收到上述错误: internal static void getCommand(string command, string arg) { command == "debug"; } 您正在编写布尔语句,而不是声明语句 根据您试图实现的目标,应为以下任一项: internal static void getCommand(string command, string arg) { // comparison if (command == "debug
internal static void getCommand(string command, string arg)
{
command == "debug";
}
您正在编写布尔语句,而不是声明语句
根据您试图实现的目标,应为以下任一项:
internal static void getCommand(string command, string arg)
{
// comparison
if (command == "debug")
{
// do something
}
}
或
您的代码当前既不做也不做。不确定代码需要做什么,但应该是其中之一。您试图在两个值之间进行比较,但对比较结果不做任何操作。即使它被编译,它也将一事无成。你希望这段代码能做什么?我只是写了字符串,我甚至还没有开始写它的用途。谢谢,你解决了我的问题!没问题,你收到的所有反对票都是不幸的。对于新手来说,这里有两个问题很容易被忽略。祝你好运
internal static void getCommand(string command, string arg)
{
// comparison
if (command == "debug")
{
// do something
}
}
internal static void getCommand(string command, string arg)
{
//assignment
command = "debug";
}