Home  |  Delphi .net Home  |  System.Enum  |  GetNames Method
GetNames  
Method  
Gets a list of the names of a specified enumeration type
Enum Class
System NameSpace
NotCF1.  Function GetNames ( EnumeratedType : Type; ) : Array of String; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns an array of strings contaiing the names for the given EnumeratedType.
 
An enumeration is essentially a set of named constants. Each name is converted into a string and stored in the dynamically built returned array.
 
The names are sorted into the name numeric constant value sequence before being returned.
Microsoft MSDN Links
System
System.Enum
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  Names : Array of String;
  i     : Integer;

begin
  // Get the list of enumeration names
  Names := System.Enum.GetNames(TypeOf(System.DayOfWeek));

  // Display the list
  for i := 0 to Length(Names)-1 do
    Console.WriteLine(Names[i]);

  Console.ReadLine;
end.
Show full unit code
  Sunday
  Monday
  Tuesday
  Wednesday
  Thursday
  Friday
  Saturday
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author