Skip to main content
Active reading.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

There are two ways to iterate an Enum:

1. var values =  Enum.GetValues(typeof(myenum))
2. var values =  Enum.GetNames(typeof(myenum))

The first will give you values in form on aan array of object**object**s, and the second will give you values in form of an array of String**String**s.

Use it in a foreach loop as below:

foreach(var value in values)
{
    // Do operations here
}

There are two ways to iterate an Enum:

1. var values =  Enum.GetValues(typeof(myenum))
2. var values =  Enum.GetNames(typeof(myenum))

The first will give you values in form on a array of object, and the second will give you values in form of array of String.

Use it in foreach loop as below:

foreach(var value in values)
{
    //Do operations here
}

There are two ways to iterate an Enum:

1. var values =  Enum.GetValues(typeof(myenum))
2. var values =  Enum.GetNames(typeof(myenum))

The first will give you values in form on an array of **object**s, and the second will give you values in form of an array of **String**s.

Use it in a foreach loop as below:

foreach(var value in values)
{
    // Do operations here
}
deleted 27 characters in body
Source Link
Termininja
  • 7.1k
  • 12
  • 51
  • 50

There are two ways to iterate an Enum:

1.

 var values =  Enum.GetValues(typeof(myenum))
1. var values =  Enum.GetValues(typeof(myenum))
2. var values =  Enum.GetNames(typeof(myenum))

AboveThe first will give you values in form on a array of object.

2.

var values = Enum.GetNames(typeof(myenum))

Above, and the second will give you values in form of array of String.

Use Use it in foreach loop as below:

foreach(var value in values)
{
    //Do operations here
}

There are two ways to iterate an Enum:

1.

 var values =  Enum.GetValues(typeof(myenum))

Above will give you values in form on a array of object.

2.

var values = Enum.GetNames(typeof(myenum))

Above will give you values in form of array of String.

Use it in foreach loop as below:

foreach(var value in values)
{
    //Do operations here
}

There are two ways to iterate an Enum:

1. var values =  Enum.GetValues(typeof(myenum))
2. var values =  Enum.GetNames(typeof(myenum))

The first will give you values in form on a array of object, and the second will give you values in form of array of String.

Use it in foreach loop as below:

foreach(var value in values)
{
    //Do operations here
}
added 240 characters in body
Source Link
Kylo Ren
  • 8.9k
  • 6
  • 44
  • 68
Enum.GetValues(typeof(myenum))

There are two ways to iterate an Enum:

this1.

 var values =  Enum.GetValues(typeof(myenum))

Above will give you values in form on a array of objectobject.

Enum.GetNames(typeof(myenum))

2.

var values = Enum.GetNames(typeof(myenum))

thisAbove will give you values in form of array of stringString.

Use it in foreach loop as below:

foreach(var value in values)
{
    //Do operations here
}
Enum.GetValues(typeof(myenum))

this will give you values in form on a array of object.

Enum.GetNames(typeof(myenum))

this will give you values in form of array of string.

There are two ways to iterate an Enum:

1.

 var values =  Enum.GetValues(typeof(myenum))

Above will give you values in form on a array of object.

2.

var values = Enum.GetNames(typeof(myenum))

Above will give you values in form of array of String.

Use it in foreach loop as below:

foreach(var value in values)
{
    //Do operations here
}
Source Link
Kylo Ren
  • 8.9k
  • 6
  • 44
  • 68
Loading