Solved

iff statement

Posted on 2004-10-20
4
4,383 Views
Last Modified: 2008-01-09
Hi guys:

I need the syntax of iff statement in C# (if there is one) . thanks
0
Comment
Question by:rxraza
4 Comments
 
LVL 3

Expert Comment

by:aacool
ID: 12359575
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
 
LVL 48

Accepted Solution

by:
AlexFM earned 50 total points
ID: 12359753
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
 
LVL 22

Expert Comment

by:cookre
ID: 12359823
On the off chance you meant 'iif':

boolexpr ? expr1 : expr2

If boolexpr is TRUE, the result is expr1, otherwise the result is expr2
0
 

Author Comment

by:rxraza
ID: 12359969
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now