请问下面的代码怎么修改?
if ((a = 1) || (4 <= a <= 5)||(a = 23))
textBox5.Text = "***";
else if (1 < a < 4)
textBox5.Text = "****";
else if (5 < a < 23)
textBox5.Text = "*****";
我用的是c#,windows窗口程序编译,系统提示的是“<=”和“<”无法应用于bool和int的类型操作数
这个该怎么解决叻?
if ((a = 1) || (4 <= a <= 5)||(a = 23))
textBox5.Text = "***";
else if (1 < a < 4)
textBox5.Text = "****";
else if (5 < a < 23)
textBox5.Text = "*****";
我用的是c#,windows窗口程序编译,系统提示的是“<=”和“<”无法应用于bool和int的类型操作数
这个该怎么解决叻?
if ((a == 1) || (4 <= a <= 5)||(a == 23))
原因是,a=1和a=23 是赋值语句,a==23才是返回true/false的语句。所以会出现错误
必须这样写 4 <= a && a <= 5C#中,==是用来 判断相等 用的,=是 用来做赋值 用的
textBox5.Text = "***";
else if (1 < a && a< 4)
textBox5.Text = "****";
else if (5 < a&&a < 23)
textBox5.Text = "***";
else if (1 < a&&a < 4)
textBox5.Text = "****";
else if (5 < a&&a < 23)
textBox5.Text = "*****";