rxraza
asked on
iff statement
Hi guys:
I need the syntax of iff statement in C# (if there is one) . thanks
I need the syntax of iff statement in C# (if there is one) . thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
On the off chance you meant 'iif':
boolexpr ? expr1 : expr2
If boolexpr is TRUE, the result is expr1, otherwise the result is expr2
boolexpr ? expr1 : expr2
If boolexpr is TRUE, the result is expr1, otherwise the result is expr2
ASKER
Thanks guys for the response.
C#: str = ((result < 0) ? "less than" : ((result > 0) ? "greater than" : "equal to"));
is what I was looking for.
C#: str = ((result < 0) ? "less than" : ((result > 0) ? "greater than" : "equal to"));
is what I was looking for.
There is no single keyword or for iff in C#.
What exactly are you trying to implement with the iff statement?
You might need two if statements to achieve your goal.
In some cases, the effect of iff is achieved internally, .e.g.
MyClass myClass = new MyClass();
if (myClass is MyClass)
{
//executed
}
the is keyword will evaluate to true if and only if the object is of the type MyClass.