Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# switch ?
Message
De
19/04/2003 18:13:39
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00779532
Message ID:
00779539
Vues:
14
Dmitry,

The switch/case statement in C# is definitely way more limiting than in VFP. You can't do what you're trying to do with a switch/case, you'd need to use if statements. The only part of the switch/case that you've used that is actually valid is just this:
switch (iTime)
{
  case iBegin :
       Response.Write("iTime = iBegin");
       break;
  case iEnd:
      Response.Write("iTime = iEnd");
      break;
}
You can only test that the variable is equal to what you specify in the case, that's it.

~~Bonnie


>I am probably misunderstanding something about use of switch statement. My understanding was that switch should function just like do case in VFP. Yet I find switch quite limitted, unless I misunderstand something.
>
>Here is a simple example of switch that does not work:
>
>int iTime = 5;
>int iBegin = 5;
>int iEnd = 7;
>
>switch (iTime)
> {
> case iTime == iBegin:
> Response.Write("iTime = iBegin");
> break;
> case iTime > iBegin && iTime < iEnd:
> Response.Write("iTime > iBegin and < iEnd");
> break;
> case iTime == iEnd:
> Response.Write("iTime = iEnd");
> break;
> }
>
>Yet, in VFP you can use DO CASE to compare the three values in a manner shown in the example above.
>
>What am I missing?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform