Posted By

denakitan on 10/20/12


Tagged

iteration enum Net basics examples c#


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Priestd09
danfinrud55


.NET - C# - Enum - Basics


 / Published in: C#
 

Examples of use of Enum type, like how to iterate its items.

  1. public enum StudioGhibliDirectors
  2. {
  3. HayaoMiyazaki,
  4. IsaoTakahata,
  5. TomomiMochizuki,
  6. YoshifumiKondo,
  7. HiroyukiMorita,
  8. GoroMiyazaki,
  9. HiromasaYonebayashi
  10. }
  11.  
  12. public class EnumIteration
  13. {
  14. public static void Main(string[] args)
  15. {
  16. Console.WriteLine("Studio Ghibli directors:");
  17.  
  18. foreach (StudioGhibliDirectors director in Enum.GetValues(typeof(StudioGhibliDirectors)))
  19. {
  20. Console.WriteLine(director.ToString());
  21. }
  22. }
  23. }

Report this snippet  

You need to login to post a comment.