|
<< Click to Display Table of Contents >> Enum - foreach |
![]() ![]()
|
enum Polygon
{
Triangle = 3,
Quadrilateral,
Pentagon,
Hexagon
}
static void Main(string[] args)
{
foreach (Polygon p in Enum.GetValues(typeof(Polygon)))
{
Console.WriteLine("{0} ({1})", p, (int)p);
}
}
/* OUTPUT
Triangle (3)
Quadrilateral (4)
Pentagon (5)
Hexagon (6)
*/