• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4423
  • Last Modified:

iff statement

Hi guys:

I need the syntax of iff statement in C# (if there is one) . thanks
0
rxraza
Asked:
rxraza
1 Solution
 
aacoolCommented:
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.
0
 
AlexFMCommented:
If you mean VB IIf statement, there is C# equivalent:

VB: str = IIf(result < 0, "less than", IIf(result > 0, "greater than", "equal to"))
C#: str = ((result < 0) ? "less than" : ((result > 0) ? "greater than" : "equal to"));
0
 
cookreCommented:
On the off chance you meant 'iif':

boolexpr ? expr1 : expr2

If boolexpr is TRUE, the result is expr1, otherwise the result is expr2
0
 
rxrazaAuthor Commented:
Thanks guys for the response.

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

is what I was looking for.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now