Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# switch Gripe
Message
De
03/01/2009 11:37:38
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01370558
Message ID:
01370839
Vues:
36
>You are welcome. Congrats on MVP status again.
>Things that are worth putting into enums are usually switch'd on at some point and the autocomplete is very handy.


Thanks ... even though there obviously things I still don't know. <g> I use enums frequently, so this is a handy tip to know about!

~~Bonnie




>
>>I didn't know about that cool little IDE trick, Einar! Thanks!
>>
>>~~Bonnie
>>
>>
>>
>>
>>>>Hi Einar, I like the sound of switch on enum - could you post a code snippet ?
>>>
>>>Define the enum:
>>>
>>>private enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };
>>>
>>>Which is short for:
>>>
>>>private enum Days : int
>>>		{
>>>			Sunday = 0,
>>>			Monday = 1,
>>>			Tuesday = 2,
>>>			Wednesday = 3,
>>>			Thursday = 4,
>>>			Friday = 5,
>>>			Saturday = 6
>>>		};
>>>
>>>
>>>The trype switch and and press tab , then type in the variable that is that enum type and press enter. Auto complete fills out the following for you:
>>>
>>>Days days = Days.Friday;
>>>			switch (days)
>>>			{
>>>				case Days.Sunday:
>>>					break;
>>>				case Days.Monday:
>>>					break;
>>>				case Days.Tuesday:
>>>					break;
>>>				case Days.Wednesday:
>>>					break;
>>>				case Days.Thursday:
>>>					break;
>>>				case Days.Friday:
>>>					break;
>>>				case Days.Saturday:
>>>					break;
>>>				default:
>>>					break;
>>>			}
>>>
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