Answers for "loop through an enum"

C#
3

traversing an enum c#

var values = Enum.GetValues(typeof(Foos)).Cast<Foos>();
Posted by: Guest on April-14-2020
1

loop over enum values

var values = Enum.GetValues(typeof(EnumName));

foreach (var value in values)
{
	Combobox.Items.Add(value.ToString());
}
Posted by: Guest on May-21-2020
0

how to loop through a python enum

from enum import Enum
class Country(Enum):
    Afghanistan = 93
    Albania = 355
    Algeria = 213
    Andorra = 376
    Angola = 244
    Antarctica = 672
for data in Country:
    print('{:15} = {}'.format(data.name, data.value))
Posted by: Guest on May-22-2021

C# Answers by Framework

Browse Popular Code Answers by Language