Returns a zero-based, one-dimensional string array that contains the names of the constants of the specified enumeration type.
- enumType
- A Type that specifies the type of an enumeration.
A string vector of the names of the constants in enumType. The elements of the vector are sorted by the values of the enumerated constants. If multiple constants have the same value, the order in which their names appear in the vector, relative to each other, is unspecified.
Type Reason ArgumentNullException enumType is a null reference. ArgumentException enumType is not a Type that describes a Enum .
Documentation for this section has not yet been entered.
The following example demonstrates the Enum.GetNames(Type) method.
C# Example
using System; public enum Colors { Red, White, Blue }; public class enumGetNames { public static void Main() { int i = 0; String[] strAry = Colors.GetNames( typeof(Colors) ); foreach (String str in strAry) { Console.Write("The value indexed '{0}' ", i++ ); Console.WriteLine("is {0}.", str); } } }The output is
The value indexed '0' is Red.
The value indexed '1' is White.
The value indexed '2' is Blue.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0