Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#10

AW: Unterschied zwischen Variant und Generics

  Alt 6. Jun 2014, 15:22
In Delphi:

Delphi-Quellcode:
procedure TForm1.swapTwoValues<T>(var Value1, Value2: T);
var tmp: T;
begin
  tmp := Value1;
  Value1 := Value2;
  Value2 := tmp;
end;
Aufruf:

Delphi-Quellcode:
swapTwoValues<Integer>(someInt1, someInt2);
swapTwoValues<String>(someStr1, someStr2);
swapTwoValues<TMyRecord>(someRec1, someRec2);
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."

Geändert von Neutral General ( 6. Jun 2014 um 15:24 Uhr)
  Mit Zitat antworten Zitat