Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# Equivalent To VFP DO CASE
Message
De
30/12/2004 03:23:45
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
00972871
Message ID:
00973191
Vues:
14
>>>I am trying to convert some strings based on conditions. In VFP I would do something like:
>>>
>>>
>>>DO CASE
>>>CASE condition a
>>>   && code here
>>>CASE condition b
>>>   && code here
>>>OTHERWISE
>>>   && code here
>>>ENDCASE
>>>
>>>
>>>How would this be coded in C#?
>>>
>>>TIA, Kevin
>>
>>There is not an exact match in C# (as it can be used in VFP in different ways).
>>One match is 'switch'. Expression result is determined at top and one of sbyte,byte,short,ushort,int,uint,long,ulong,char,string or enum type. In VFP's case statements blocks are implicitly 'broken' and there is no fall through. In C# fall through is not allowed but you must explicitly 'break' (break,go to,return..). ie:
>>
>>
>>int result = SomeMethod();
>>switch (result)
>>{
>> case 0:
>>   // ...
>>   break;
>> case 1:
>>   // ...
>>  break;
>> otherwise
>>  //...
>>}
>>
>
>Cetin,
>
>Shouldn't this be
switch (result)
>{
>  case 0:
>    // ...
>    break;
>  case 1:
>    // ...
>    break;
>  default:
>    //...
>    break;
>}
?

Yes, it'd be:) Happy new year BTW.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform