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

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
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.
   2
   5
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author