Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP inlist() in c#
Message
De
29/01/2013 06:05:30
 
 
À
29/01/2013 05:47:51
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01320903
Message ID:
01564458
Vues:
54
>>>>>>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....

I find it nice also. But for some people it is way too complicated - rolling my eyes ;)
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform