开发者

Declaring fixed size string properties in Delphi

开发者 https://www.devze.com 2023-01-14 15:09 出处:网络
How do I declare a fixed size string property in Delphi? This is what I want to do, but I r开发者_JAVA百科eceive an error:

How do I declare a fixed size string property in Delphi?

This is what I want to do, but I r开发者_JAVA百科eceive an error:

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

The compiler error reads: 'INDEX, READ, or WRITE clause expected, but '[' found'.


try this

type
Str20=string[20];

TMyObject = class(TObject)
private
  FName : Str20;
public
  property Name : Str20 read FName write FName;     //<-- error
end;
0

精彩评论

暂无评论...
验证码 换一张
取 消