GetNames Method

Enum.GetNames Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Retrieves an array of the names of the constants in a specified enumeration.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static string[] GetNames(
	Type enumType
)

Parameters

enumType
Type: System.Type
An enumeration type.

Return Value

Type: System.String []
A string array of the names of the constants in enumType.

ExceptionCondition
ArgumentNullException

enumType is null.

ArgumentException

enumType is not an Enum.

The elements of the return value array are sorted by the binary values of the enumerated constants (that is, by their unsigned magnitude). If there are enumerated constants with the same value, the order of their corresponding names is unspecified.

The following example illustrates the use of the GetNames method.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft