Returns a zero-based, one-dimensional array of the values of the constants of the specified enumeration type.
- enumType
- The Type of an enumeration.
A vector of the enumeration type specified by enumType containing the values of the constants in enumType. The elements of the array are sorted by the values of the enumeration constants. If multiple constants have the same value, the value of each is included in the array.
Type Reason ArgumentNullException enumType is a null reference. ArgumentException enumType is not an enumeration type.
Documentation for this section has not yet been entered.
The following example demonstrates the Enum.GetValues(Type) method.
C# Example
using System; public enum Colors { Red = 1, White = 2, Blue = 4 } public class enumGetValues { public static void Main() { Array valueAry = Enum.GetValues(typeof(Colors)); foreach (int i in valueAry) { Console.WriteLine("The value of element {0} is {1}", Enum.Format(typeof(Colors), i, "g"),i); } } }The output is
The value of element Red is 1.
The value of element White is 2.
The value of element Blue is 4.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0