How to Iterate Enum in C# ?

The Enum values can be iterated using the Enum.GetValues method.

How to Iterate Enum in C# ?

Below is a sample sourecode that demonstrates How to Iterate Enum in C# (Winforms)?

internal enum ProgrammingLanguages

{

CSharp,

Java = 1,

Erlang = 2,

Delphi = 3,

PHP

}
foreach (var item in Enum.GetValues(typeof(ProgrammingLanguages)))

{

MessageBox.Show(item.ToString());

}
%d bloggers like this: