为什么我得到"无法隐式转换类型'十进制'到'bool'"错误?

2 c# conditional if-statement boolean decimal

我想在numericUpDown的值改变时隐藏一些东西,所以我写了这个:

if (numericUpDown1.Value = 1)
{
    Label1.Hide();
}
Run Code Online (Sandbox Code Playgroud)

但我收到此错误消息:

无法将类型'decimal'隐式转换为'bool'

为什么会这样?

Zac*_*ena 9

我认为你的意思是" if (numericUpDown1.Value == 1)".

在大多数语言中," =="是对相等性的测试,而" ="是赋值运算符.