运营商&&不能应用于system.drawing.color和bool类型的操作数 [英] Operator && cannot be applied to operands of type system.drawing.color and bool
问题描述
你好,我有一个问题,下面结合两个条件,我尝试很多东西使用这两个条件在一起,但它没有用,如果有人可以帮助我或有办法解决这个我会有希望< br $>
谢谢..
我尝试过:
if (e.Row.RowType == DataControlRowType.DataRow)
{
// 把你的控制名称来获取然后检查你的值
标签lbl = e.Row.FindControl( Label17) as 标签;
if (lbl.Text == ملغيCancled)
{
e.Row.BackColor = Color.Red&&金额== 0 ; // ----->问题在这里
return ; // 将在此处停止
}
}
问题是&&是一个boolan操作,因此是== - 但是运算符优先级的组合在两个opertors的每一侧都没有相同的类型:
(Color.Red && Amount)== 0将bool与int进行比较。
Color.Red&& (金额== 0)将颜色与布尔值进行比较。
因此编译抱怨。
我怀疑你打算使用二进制文件AND:
(Color.Red& Amount)== 0但是在不知道你的项目的情况下,我无法说出来。
您的意思是:
if (e.Row.RowType = = DataControlRowType.DataRow)
{
// 将控制名称放在此处然后检查为你的价值
标签lbl = e.Row.FindControl( Label17) as 标签;
if (lbl.Text == ملغيCancled)
{
e.Row.BackColor = Color.Red;
金额= 0 ;
return ;
}
}
e.Row.BackColor = Color.Red&&金额== 0 ; // ----->问题在这里
是的,这段代码毫无意义,所以没有可能的纠正因为你没有告诉我们它应该做什么。 br />
Quote:<
/ div>我遇到了将两个条件合并到下面的问题
Color.Red
不是条件。
解释你想要什么要做。
[更新]
这也没有意义:
e。 Row.BackColor =(Color.Red& Amount)== 0 ;
hello, I have a problem with Combine two condition down below, I try many things to use that two condition together but it didn't work, if someone can help me or have some way to solve this I will be hopeful
Thanks..
What I have tried:
if (e.Row.RowType == DataControlRowType.DataRow)
{
//put your control name here to get and then check for your value
Label lbl = e.Row.FindControl("Label17") as Label;
if (lbl.Text == "ملغي Cancled ")
{
e.Row.BackColor = Color.Red && Amount == 0; // -----> Problem is here
return; //will stop here
}
}
The problem is that "&&" is a boolan operation, and so is "==" - but no combination of operator precedence ends up with the same types on each side of both opertors:
(Color.Red && Amount) == 0is comparing a bool to an int.
Color.Red && (Amount == 0)is comparing a Color to a bool.
So the compile complains.
I suspect you meant to use the binary AND:
(Color.Red & Amount) == 0But without knowing your project, I can't really tell.
Do you mean:
if (e.Row.RowType == DataControlRowType.DataRow) { //put your control name here to get and then check for your value Label lbl = e.Row.FindControl("Label17") as Label; if (lbl.Text == "ملغي Cancled ") { e.Row.BackColor = Color.Red; Amount = 0; return; } }
e.Row.BackColor = Color.Red && Amount == 0; // -----> Problem is here
Yes, this code is meaningless, so there is no possible correction because you didn't told us what it is supposed to do.
Quote:<
/div>I have a problem with Combine two condition down below
Color.Red
is not a condition.
Explain what you want to do.
[Update]
This have no meaning either:
e.Row.BackColor = (Color.Red & Amount) == 0;
这篇关于运营商&&不能应用于system.drawing.color和bool类型的操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!