[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

iff statement

Posted on 2004-10-20
4
Medium Priority
?
4,412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

649 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