27 Ağustos 2012 Pazartesi

Delphi XE3 Helpers

XE3 ile gelen yeniliklerden biride daha önce record'lara ve class'lara yazdığımız uzanım fonksiyonlarını artık temel veritiplerine de yazabiliyoruz.Bu güzel bir durum.Bak şimdi oldu :)
unit Unit1;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs;

type
  TDoubleHelper = record helper for Double
    function KareKokAl: Double;
  end;

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
 sayi:Double;
begin
 sayi:=100;
 ShowMessage(FloatToStr(sayi.KareKokAl));
end;

{ TDoubleHelper }
function TDoubleHelper.KareKokAl: Double;
begin
  Result:=Sqrt(Self);
end;

end.

Hiç yorum yok:

Yorum Gönder