Returns a zero-based, one-dimensional array of the values of the constants of the
specified enumeration type.
[Edit]
[System.Runtime.InteropServices.ComVisible(true)] public static Array GetValues (Type enumType) |
|
Parameters
- enumType
- The Type of an enumeration.
[Edit]
Returns
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.
[Edit]
Exceptions
Remarks
Example
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.
Requirements
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0