Home  |  Delphi .net Home  |  System.Enum  |  Parse Method
  
Parse  
Method  
Builds an enum object from an enum type and a string of enum values
Enum Class
System NameSpace
NotCF1.  Function Parse ( EnumeratedType : Type; ValueString : String ) : Object; Static;
NotCF2.  Function Parse ( EnumeratedType : Type; ValueString : String; IgnoreCase : Boolean ) : Object; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
An enumerated object of type EnumeratedType is created, set to one or more values given by the ValueString.
 
Multiple values are specified with separating commas, and are only meaningful for enumerations that have the [FlagsAttribute] - in other words, they are a set of independant flag values.
 
The IgnoreCse option allows the values to be specified without regard to case.
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Enum
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

type
  // An enum treated as a set
  [FlagsAttribute]
  Qualities  = (Sexy = 1, Clever = 2, Handsome = 4);

var
  Brian : System.Object;

begin
  // Set Brian to be just Sexy
  Brian := Sexy;
  Console.WriteLine('Brain is ' + Brian.ToString);

  // Set Brian as Clever and Handsome
  Brian := System.Enum.Parse(TypeOf(Qualities), 'Clever, Handsome');
  Console.WriteLine('Brain is ' + Brian.ToString);

  Console.ReadLine;
end.
   Brain is Sexy
   Brain is Clever, Handsome
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author