To enumerate an Enum in C# and VB.NET you can use the snippet below.
Sample C#
public enum TestEnum { These = 0, Are = 1, Sample = 2, Enums = 3, Duplicates = 3, Included = 4 } static void Main(string[] args) { foreach (var testEnum in Enum.GetNames(typeof(TestEnum))) { System.Console.WriteLine(testEnum); } Console.Read(); }
Sample VB.NET
Public Enum TestEnum These = 0 Are = 1 Sample = 2 Enums = 3 Duplicates = 3 Included = 4 End Enum Private Shared Sub Main(args As String()) For Each testEnum As var In [Enum].GetNames(GetType(TestEnum)) System.Console.WriteLine(testEnum) Next Console.Read() End Sub
RT @CodeSnippetsNET: How to enumerate an Enum in C# and #VB .NET http://t.co/JnkBCGkAa9 #dotnet #csharp #visualstudio #programming #code #d…
RT @CodeSnippetsNET: How to enumerate an Enum in C# and #VB .NET http://t.co/JnkBCGkAa9 #dotnet #csharp #visualstudio #programming #code #d…
RT @CodeSnippetsNET: How to enumerate an Enum in C# and #VB .NET http://t.co/JnkBCGkAa9 #dotnet #csharp #visualstudio #programming #code #d…
RT @CodeSnippetsNET: How to enumerate an Enum in C# and #VB .NET http://t.co/JnkBCGkAa9 #dotnet #csharp #visualstudio #programming #code #d…