loop through an enum csharp
Code Example - loop through an enum csharp
public enum Days {
Monday,
Tuesday,
Wednesday
}
foreach(Days day in Enum.GetValues(typeof(Days))) {
}
loop through all enum values in csharp
var values = Enum.GetValues(typeof(Foos));
foreach(Foos foo in values) {
// do something, use foo
}
// or
foreach(Foos foo in Enum.GetValues(typeof(Foos))) {
// do something, use foo
}
csharp foreach enum
enum Foos {
Foo,
Bar,
}
foreach(Foos val in Enum.GetValues(typeof(Foos))) {
//Do whatever with the value :D
}
enum foreach
foreach (Suit suit in (Suit[]) Enum.GetValues(typeof(Suit)))
{
}
Loop through enum csharp
enum Foos {
Foo,
Bar,
}
foreach(Foos val in Enum.GetValues(typeof(Foos))) {
//Do whatever with the value :D
}
traversing an enum csharp
var values = Enum.GetValues(typeof(Foos)).Cast<Foos>();
csharp iterate enum
var values = Enum.GetValues(typeof(Foos));
enum get all values csharp
//typed
var values = Enum.GetValues(typeof(Foos)).Cast<Foos>()
csharp get all enum values
var values = Enum.GetValues(typeof(Foos));