How to loop through an enum in C#
Loading
How to loop through an enum in C#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajanikant HawaldarPosted Jul 12, 2022, 9:10 AM
In C# an enum is used to assign constant names to a group of numeric integer values. It makes constant values more readable, for example, WeekDays.Monday is more readable than number 0 when referring to the day in a week.An enum can be looped through using Enum.GetNames(), Enum.GetNames(), Enum.GetValues(), or Enum.GetValues() static methods with the foreach loop.The following example gets the names of an enum using the Enum.GetNames() method.
Mahesh ChandPosted Jul 12, 2022, 1:15 PM
Vishal YelvePosted Jul 12, 2022, 11:31 AM
OR