问题描述
大家好,
hi all,
string[] result=new string [4];
string accessnumber = null;
accessnumber = "";
result = clsObj.FnCheckAccessNo();
if (result[0] == 1)
{
accessnumber = result[2];
}
我尝试使用这种情况来显示以下错误,如果有人知道,请告诉我..
运算符"=="不能应用于类型为"string"和"int"的操作数
源错误:
第160行:accessnumber =";
第161行:result = clsObj.FnCheckAccessNo();
第162行: 如果(结果[0] == 1)
第163行:{
第164行:accessnumber = result [2];
Am try to use this condition it shows the follwing error, please let me know if anybody knows..
Operator ''=='' cannot be applied to operands of type ''string'' and ''int''
Source Error:
Line 160: accessnumber = "";
Line 161: result = clsObj.FnCheckAccessNo();
Line 162: if (result[0] == 1)
Line 163: {
Line 164: accessnumber = result[2];
推荐答案
int a = 0;
if (a == 0) ...
或两个字符串
or two Strings
string word = "Hello";
if (word == "Bark") ...
但不是
but not
if (a == word)
...
也许现在您看到代码中的问题了吗?
...
Maybe now you see what is wrong in your code?
if (result[0] == (1).ToString())
或
or
if (result[0] == "1")
祝您编码愉快!
:)
Happy Coding!
:)
这篇关于运算符'=='不能应用于类型为'string'和'int'的操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!