Answers for "enum values loop"

C#
5

enum loop

enum Foos {
  Foo,
  Bar,
}

foreach(Foos val in Enum.GetValues(typeof(Foos))) {
  //Do whatever with the value :D
}
Posted by: Guest on October-07-2020
3

loop over all values in enum

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

C# Answers by Framework

Browse Popular Code Answers by Language