How to define constant-Records?
What if you like to have a set of constants collected into a record structure? Well, it looks crazy but it’s possible:
[code lang=”delphi”]type
TRec = record
i1 : integer;
s1 : string;
b1 : Boolean;
end;
const
MyConstRec : TRec = (i1 : 1;
s1 : ‘test’;
b1 : TRUE);
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(MyConstRec.s1); //will show: ‘test’
end;
[/code]
[tags]Delphi, Misc, Records[/tags]
0 Kommentare zu “Records: How to define a ‘constant record’?”