Home  |  Delphi .net Home  |  System.Convert  |  ToInt16 Method
ToInt16  
Method  
Converts data from one data type to a Int16 data type
Convert Class
System NameSpace
CF1.  Function ToInt16 ( Value : Boolean; ) : Int16;
CF2.  Function ToInt16 ( Value : Byte; ) : Int16;
CF3.  Function ToInt16 ( Value : Char; ) : Int16;
CF4.  Function ToInt16 ( Value : DateTime; ) : Int16;
CF5.  Function ToInt16 ( Value : SmallInt; ) : Int16;
CF6.  Function ToInt16 ( Value : ShortInt; ) : Int16;
CF7.  Function ToInt16 ( Value : Integer; ) : Int16;
CF8.  Function ToInt16 ( Value : Int64; ) : Int16;
CF9.  Function ToInt16 ( Value : UInt64; ) : Int16;
CF10.  Function ToInt16 ( Value : Word; ) : Int16;
CF11.  Function ToInt16 ( Value : Single; ) : Int16;
CF12.  Function ToInt16 ( Value : Double; ) : Int16;
CF13.  Function ToInt16 ( Value : Decimal; ) : Int16;
CF14.  Function ToInt16 ( Value : Int16; ) : Int16;
CF15.  Function ToInt16 ( Value : String; ) : Int16;
CF16.  Function ToInt16 ( Value:StringValue : String; FormatProvider : IFormatProvider; ) : Int16;
CF17.  Function ToInt16 ( Value : Object; ) : Int16;
CF18.  Function ToInt16 ( Value:ObjectValue : Object; FormatProvider : IFormatProvider; ) : Int16; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Attempts to transfer the value from one of the given Value data types to Int16.
 
The optional FormatProvider parameter determines the parsing rules and is beyond the scope of this article.
Notes
An exception is thrown if the conversion fails.
Microsoft MSDN Links
System
System.Convert
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  value : Int16;
  myStr : String;

begin
  myStr  := '12345';

  value  := System.Convert.ToInt16(myStr);

  Console.WriteLine(value.ToString);

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