Home  |  Delphi .net Home  |  System.Enum  |  IsDefined Method
  
IsDefined  
Method  
Determines whether an object has a valid enumerated value
Enum Class
System NameSpace
CF1.  Function IsDefined ( EnumeratedType : Type; Value : Object ) : Boolean; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns true if the Value is a valid value for the given EnumeratedType.
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}

var
  Day    : DayOfweek;
  DayNum : Integer;

begin
  Day := DayOfWeek.Thursday;

  if System.Enum.IsDefined(TypeOf(DayOfWeek), Day)
  then Console.WriteLine('{0} is a week day',     Day)
  else Console.WriteLine('{0} is not a week day', Day);

  DayNum := 6; // Saturday

  if System.Enum.IsDefined(TypeOf(DayOfWeek), DayOfWeek(DayNum))
  then Console.WriteLine('{0} is a week day',     DayOfWeek(DayNum))
  else Console.WriteLine('{0} is not a week day', DayOfWeek(DayNum));

  DayNum := 11; // Invalid day of week value

  if System.Enum.IsDefined(TypeOf(DayOfWeek), DayOfWeek(DayNum))
  then Console.WriteLine('{0} is a week day',     DayOfWeek(DayNum))
  else Console.WriteLine('{0} is not a week day', DayOfWeek(DayNum));

  Console.ReadLine;
end.
   Thursday is a week day
   Saturday is a week day
   11 is not a week day
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author