Link to home
Start Free TrialLog in
Avatar of rxraza
rxraza

asked on

iff statement

Hi guys:

I need the syntax of iff statement in C# (if there is one) . thanks
Avatar of aacool
aacool

The term iff is used for "if, and only if"

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.
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
On the off chance you meant 'iif':

boolexpr ? expr1 : expr2

If boolexpr is TRUE, the result is expr1, otherwise the result is expr2
Avatar of rxraza

ASKER

Thanks guys for the response.

C#: str = ((result < 0) ? "less than" : ((result > 0) ? "greater than" : "equal to"));

is what I was looking for.