Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP inlist() in c#
Message
From
29/01/2013 05:47:51
 
 
To
29/01/2013 03:54:00
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01320903
Message ID:
01564455
Views:
65
>>>>>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....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform