Home  |  Delphi .net Home  |  System.Char  |  GetNumericValue Method
GetNumericValue  
Method  
Tries to get the numeric value of a numeric character
Char Structure
System NameSpace
CF1.  Function GetNumericValue ( NumericChar : Char; ) : Double;
CF2.  Function GetNumericValue ( CharString:StringCharString : String; Index : Integer; ) : Double; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
GetNumericValue attempts to treat the supplied Char as a numeric digit character (IsDigit = true), returning this value as a Double number.
 
If the Char cannot be treated as a numeric digit, -1 is returned.
 
The supplied Char can be from Index position in a CharString.
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.Char
 
 
An example of both syntaxes
program Project1;
{$APPTYPE CONSOLE}

var
  result  : Double;
  charStr : String;

begin
  // From a supplied character
  result := System.Char.GetNumericValue('2');
  Console.WriteLine(result.ToString);

  // From a position in a string
  charStr := '0123456789';
  result := System.Char.GetNumericValue(charStr, 5);
  Console.WriteLine(result.ToString);

  Console.ReadLine;
end.
Show full unit code
  2
  5
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author