Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP inlist() in c#
Message
De
29/01/2013 05:47:51
 
 
À
29/01/2013 03:54:00
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01320903
Message ID:
01564455
Vues:
64
>>>>>Look at the switch command
>>>>
>>>>Switch will not help me in this case as I need 3 cases:
>>>>
>>>>Both variables defined
>>>>
>>>>startTime defined
>>>>
>>>>endTime defined
>>>>
>>>>I don't see how switch can help - switch is only for checking a single variable against predefined values.
>>>
>>>That's the problem.... if its not in a blog post, you can't figure it out....Learn to think outside a blog post...
>>
>>I don't see how it could be used in any efficient way since the parameter to a switch statement must be a simple type.
>
>Considering that each if/else if has two comparisons and a case only has one comparison, I think the switch solution is more efficient
>
>You can of course
>
>if(  startTime < defaultDate )
>{  
>        if( endTime < defaultDate )
>             ;//
>        else if (endTime== defaultDate)
>            ; //
>        else
>           ;
>}
> else if (startTime == defaultDate )
>{
>        if( endTime < defaultDate )
>             ;//
>        else if (endTime== defaultDate)
>            ; //
>        else
>           ;
>}
>else
>{
>        if( endTime < defaultDate )
>             ;//
>        else if (endTime== defaultDate)
>            ; //
>        else
>           ;
>}
>
TBH, I hadn't looked at your 'switch' version. I think you are right, and personally I find it more readable....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform