by
0
4
333k
2
Top 1% !
Popular
Pearl of Wisdom
Tagged
Popularity: 3007th place
This snippet is Public
LicenseMIT_X11

C# enum iteration

This c# code allows to iterate through all element of an enum
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/321/C--enum-iteration?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public enum Suit { Spades, Hearts, Clubs, Diamonds } foreach (Suit suit in Enum.GetValues(typeof(Suit))) { Console.WriteLine(suit); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus