码迷,mamicode.com
首页 > 其他好文 > 详细

Delphi XE6 TStringHelper中的string类型转换

时间:2014-05-01 15:02:01      阅读:382      评论:0      收藏:0      [点我收藏+]

标签:style   class   ext   width   color   strong   int   string   cti   rgb   line   

类型转换:


function ToBoolean: Boolean;
function ToInteger: Integer;
function ToSingle: Single;
function ToDouble: Double;
function ToExtended: Extended;

class function ToBoolean(const S: string): Boolean;
class function ToInteger(const S: string): Integer;
class function ToSingle(const S: string): Single;
class function ToDouble(const S: string): Double;
class function ToExtended(const S: string): Extended;

class function Parse(const Value: Integer): string;
class function Parse(const Value: Int64): string;
class function Parse(const Value: Boolean): string;
class function Parse(const Value: Extended): string;
//--------------------------------------------------------------------------------
var
  S: string;
  str: string;
  n: Integer;
  b: Boolean;
  f: Double;
begin
  str := S.Parse(123);
  n := str.ToInteger;  // 123
  b := str.ToBoolean;  // True

  str := S.Parse(True);
  b := str.ToBoolean;  // True
  n := str.ToInteger;  // -1

  str := S.Parse(3.14159260000);
  f := str.ToDouble;  //3.1415926
end;

Delphi XE6 TStringHelper中的string类型转换,码迷,mamicode.com

Delphi XE6 TStringHelper中的string类型转换

标签:style   class   ext   width   color   strong   int   string   cti   rgb   line   

原文地址:http://www.cnblogs.com/GodPan/p/3700732.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!