C# Type GetEnumValues

Description

Type GetEnumValues returns an array of the values of the constants in the current enumeration type.

Syntax

Type.GetEnumValues has the following syntax.


public virtual Array GetEnumValues()

Returns

Type.GetEnumValues method returns An array that contains the values. The elements of the array are sorted by the binary values (that is, the unsigned values) of the enumeration constants.

Example


/*from w  ww . j a  v a  2 s.  c o m*/
using System;

enum ABC{A,B,C}
public class MainClass{
  public static void Main(String[] argv){  
    ABC a = ABC.A;
    System.Console.WriteLine(a.GetType().GetEnumValues());
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version