错误运算符“==”不能应用于 'char' 和 'string' 类型的操作数
Error Operator '==' cannot be applied to operands of type 'char' and 'string'
我收到以下错误,我不知道如何解决。我只是想学习,但无法弄清楚这一点。我试图用一个相等的(=
)替换它,并且有很多东西但没有用,代码是:
if (keyinfo.KeyChar == "a")
{
}
这是错误:
0019 Operator '==' cannot be applied to operands of type 'char' and 'string'
如何避免出现此错误?
使用 'a'
而不是 "a"
,char
和 string
之间的区别在这里很微妙但很重要。
我收到以下错误,我不知道如何解决。我只是想学习,但无法弄清楚这一点。我试图用一个相等的(=
)替换它,并且有很多东西但没有用,代码是:
if (keyinfo.KeyChar == "a")
{
}
这是错误:
0019 Operator '==' cannot be applied to operands of type 'char' and 'string'
如何避免出现此错误?
使用 'a'
而不是 "a"
,char
和 string
之间的区别在这里很微妙但很重要。