What does result.IsVisible equal?
结果是什么.IsVisible相等?
if(a==b)
result.IsVisible = obj1.status.abc_REPORT == 'Y'
&& obj1.AnotherValue.ToBoolean() == false;
5 个解决方案
#1
That depends on the values of obj1.status.abc_Report
and obj1.AnotherValue.ToBoolean()
(and it all depends on whether a==b or not).
这取决于obj1.status.abc_Report和obj1.AnotherValue.ToBoolean()的值(这一切都取决于是否a == b)。
I'm not quite sure of what the real question is here - which bit is confusing you?
我不太确定这里真正的问题是什么 - 这让你感到困惑?
One bit which may be confusing you is the shortcircuiting && operator (and possibly the lack of bracing!)
可能让你感到困惑的一点是短路&&运算符(可能缺少支撑!)
The && operator will only evaluate its right hand side if the left hand side evaluates to true
: and the overall result of the expression is true
if and only if both sides evaluates to true
. (I'm assuming no strange user-defined conversions here.)
如果左侧的计算结果为true,则&&运算符仅评估其右侧:当且仅当双方的计算结果为true时,表达式的整体结果才为真。 (我假设这里没有奇怪的用户定义转换。)
So another way of writing it would be:
所以另一种写作方式是:
if (a == b)
{
bool visibility = false;
if (obj1.status.abc_REPORT == 'Y')
{
if (obj1.AnotherValue.ToBoolean() == false)
{
visibility = true;
}
}
result.IsVisible = visibility;
}
Note that a condition comparing Booleans, like this:
请注意比较布尔运算的条件,如下所示:
obj1.AnotherValue.ToBoolean() == false
would usually be written like this:
通常会这样写:
!obj1.AnotherValue.ToBoolean()
(Note the exclamation mark at the start - the logical "not" operator.)
(注意开头的感叹号 - 逻辑“非”运算符。)
#2
The same as this, in many less lines:
与此相同,在更少的行中:
if (a==b) {
if (obj1.status.abc_REPORT == 'Y') {
if (obj1.AnotherValue.ToBoolean() == false) {
result.IsVisible = true;
}
else {
result.IsVisible = false;
}
}
else {
result.IsVisible = false;
}
}
#3
In simple words:
简单来说:
If a is equal to b:
如果a等于b:
result will be visible only if:
结果仅在以下情况下可见:
object1's status's abc_report is Yes(Y = Yes most probably) AND object1's other value cannot be converted to a Boolean
object1的状态是abc_report是(最可能是Y =是)AND object1的其他值无法转换为布尔值
#4
I'm guess result.IsVisible is a boolean
我猜测结果.IsVisible是一个布尔值
It will be true if the following conditions are true: obj1.status.abc_REPORT == 'Y' and obj1.AnotherValue.ToBoolean() == false
如果满足以下条件,则为真:obj1.status.abc_REPORT =='Y'和obj1.AnotherValue.ToBoolean()== false
Also, a == b must be true to enter the initial if
此外,a == b必须为true才能输入初始if
#5
lets go line by line:
让我们逐行:
if(a==b)
obvious if value of a equals value of b the execute following line
显然,如果a的值等于执行以下行的b值
result.IsVisible = obj1.status.abc_REPORT == 'Y'
&& obj1.AnotherValue.ToBoolean() == false;
result is some object (maybe winforms controls etc) which has a property IsVisible set it to true if obj1.status.abc_REPORT is equal to 'Y' and also obj1.AnotherValue.ToBoolean() is equal to false;
结果是一些对象(可能是winforms控件等),如果obj1.status.abc_REPORT等于'Y'并且obj1.AnotherValue.ToBoolean()等于false,则具有属性IsVisible将其设置为true;
#1
That depends on the values of obj1.status.abc_Report
and obj1.AnotherValue.ToBoolean()
(and it all depends on whether a==b or not).
这取决于obj1.status.abc_Report和obj1.AnotherValue.ToBoolean()的值(这一切都取决于是否a == b)。
I'm not quite sure of what the real question is here - which bit is confusing you?
我不太确定这里真正的问题是什么 - 这让你感到困惑?
One bit which may be confusing you is the shortcircuiting && operator (and possibly the lack of bracing!)
可能让你感到困惑的一点是短路&&运算符(可能缺少支撑!)
The && operator will only evaluate its right hand side if the left hand side evaluates to true
: and the overall result of the expression is true
if and only if both sides evaluates to true
. (I'm assuming no strange user-defined conversions here.)
如果左侧的计算结果为true,则&&运算符仅评估其右侧:当且仅当双方的计算结果为true时,表达式的整体结果才为真。 (我假设这里没有奇怪的用户定义转换。)
So another way of writing it would be:
所以另一种写作方式是:
if (a == b)
{
bool visibility = false;
if (obj1.status.abc_REPORT == 'Y')
{
if (obj1.AnotherValue.ToBoolean() == false)
{
visibility = true;
}
}
result.IsVisible = visibility;
}
Note that a condition comparing Booleans, like this:
请注意比较布尔运算的条件,如下所示:
obj1.AnotherValue.ToBoolean() == false
would usually be written like this:
通常会这样写:
!obj1.AnotherValue.ToBoolean()
(Note the exclamation mark at the start - the logical "not" operator.)
(注意开头的感叹号 - 逻辑“非”运算符。)
#2
The same as this, in many less lines:
与此相同,在更少的行中:
if (a==b) {
if (obj1.status.abc_REPORT == 'Y') {
if (obj1.AnotherValue.ToBoolean() == false) {
result.IsVisible = true;
}
else {
result.IsVisible = false;
}
}
else {
result.IsVisible = false;
}
}
#3
In simple words:
简单来说:
If a is equal to b:
如果a等于b:
result will be visible only if:
结果仅在以下情况下可见:
object1's status's abc_report is Yes(Y = Yes most probably) AND object1's other value cannot be converted to a Boolean
object1的状态是abc_report是(最可能是Y =是)AND object1的其他值无法转换为布尔值
#4
I'm guess result.IsVisible is a boolean
我猜测结果.IsVisible是一个布尔值
It will be true if the following conditions are true: obj1.status.abc_REPORT == 'Y' and obj1.AnotherValue.ToBoolean() == false
如果满足以下条件,则为真:obj1.status.abc_REPORT =='Y'和obj1.AnotherValue.ToBoolean()== false
Also, a == b must be true to enter the initial if
此外,a == b必须为true才能输入初始if
#5
lets go line by line:
让我们逐行:
if(a==b)
obvious if value of a equals value of b the execute following line
显然,如果a的值等于执行以下行的b值
result.IsVisible = obj1.status.abc_REPORT == 'Y'
&& obj1.AnotherValue.ToBoolean() == false;
result is some object (maybe winforms controls etc) which has a property IsVisible set it to true if obj1.status.abc_REPORT is equal to 'Y' and also obj1.AnotherValue.ToBoolean() is equal to false;
结果是一些对象(可能是winforms控件等),如果obj1.status.abc_REPORT等于'Y'并且obj1.AnotherValue.ToBoolean()等于false,则具有属性IsVisible将其设置为true;