Home  |  Delphi .net Home  |  System.Char  |  IsNumber Method
  
IsNumber  
Method  
Returns true if a given character is a numeric digit character
Char Structure
System NameSpace
CF1.  Function IsNumber ( UnicodeChar : Char ) : Boolean; Static;
NotCF2.  Function IsNumber ( 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 numeric digit character.
 
Examples of numeric characters according to the MSDN documentation :
 
0123456789 Decimal digits
MCLXV Roman numerals

 
However IsNumber does not seem to recognise the roman numerals. None of the MSDN examples clarify this matter.
 
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.IsNumber('1')
  then Console.WriteLine('1 is a number character')
  else Console.WriteLine('1 is not a number character');

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

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

  Console.ReadLine;
end.
   1 is a number character
   'A' is not a number character
   '2' is a number character
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author