joy.simpson

joy.simpson

  • NA
  • 228
  • 0

How can I cycle through an enum list?

Nov 25 2003 3:12 PM
This is as far as I got. It's in VB.NET code, but after I get it to work I also have to do it in C# - it's for a class demo. I can only display one at a time. What I want to do is display each of the values in the enum list in a loop. Can I use a foreach loop to do this? I tried it and it wouldn't work. Please help. Public Enum dressize petite = 4 small = 8 medium = 12 large = 16 extralarge = 20 End Enum Module Module1 Sub Main() Dim mysize As dressize = dressize.medium Console.WriteLine("Size {0} is {1}", dressize.large, CInt(dressize.large)) Console.WriteLine("My size is {0} - {1}", CInt(mysize), mysize) Console.WriteLine() End Sub End Module

Answers (3)