Declaring Fixed-Size String Properties in Delphi

How to declare a property of a string of a fixed size in Delphi?

This is what I want to do, but I get an error:

TMyObject = class(TObject) private FName : string[20]; public property Name : string[20] read FName write FName; //<-- error end; 

Compiler Error: "An INDEX, READ, or WRITE clause is expected, but" ['found'.

+4
source share
1 answer

try it

 type Str20=string[20]; TMyObject = class(TObject) private FName : Str20; public property Name : Str20 read FName write FName; //<-- error end; 
+6
source

All Articles