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; Static;
NotCF2.  Function IsDigit ( CharString : 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
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
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.
   1 is a digit character
   'A' is not a digit character
   '2' is a digit character
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author