Home  |  Delphi .net Home  |  System.Char  |  IsDigit Method
IsDigit  
Method  
Returns true if a given character is a decimal numeric digit character
Char Structure
System NameSpace
CF1.  Function IsDigit ( UnicodeChar : Char; ) : Boolean;
NotCF2.  Function IsDigit ( CharString:StringCharString : String; Index : Integer; ) : Boolean; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns true if the Unicode character, or the character at Index position in CharString is a decimal numeric digit character.
 
Decimal numeric characters :
 
0123456789 Decimal digits

 
Do not use this if you are simply looking to parse a normal decimal string - use IsDigit.
Notes
Very Important : Methods in .Net treat strings as starting at 0, unlike traditional Delphi where they started at 1.

Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Char
 
 
An example of both syntaxes
program Project1;
{$APPTYPE CONSOLE}

var
  myStr  : String;

begin
  if System.Char.IsDigit('1')
  then Console.WriteLine('1 is a digit character')
  else Console.WriteLine('1 is not a digit character');

  myStr := 'A2';
  if System.Char.IsDigit(myStr, 0)  // Note 0 based index
  then Console.WriteLine('''' + myStr[1] + ''' is a digit character')
  else Console.WriteLine('''' + myStr[1] + ''' is not a digit character');

  if System.Char.IsDigit(myStr, 1)  // Note 0 based index
  then Console.WriteLine('''' + myStr[2] + ''' is a digit character')
  else Console.WriteLine('''' + myStr[2] + ''' is not a digit character');

  Console.ReadLine;
end.
Show full unit code
  1 is a digit character
  'A' is not a digit character
  '2' is a digit character
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author