Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
If statement
Message
De
28/02/2008 10:50:13
 
 
À
28/02/2008 09:39:38
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01297350
Message ID:
01297388
Vues:
12
Jerry,

this

>if (myvar1 == "") myvar = myvar2; myvar = myvar1;

is the same as this

> if (myvar1 == "") myvar = myvar2;
> myvar = myvar1;

Which means, that "myvar = myvar1" will always be executed.

If you want an if...else construct in a single line code, you might use the following syntax:

myvar = (myvar1=="") ? myvar2 : myvar1;

It's similar to the IIF() function of VFP.
Holger Vorberg
Germany
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform