【发布时间】:2017-02-21 13:41:52
【问题描述】:
我有这个代码:
type
TMyClass = class
private
procedure SetKeyValue(const Key: WideString; Value: Widestring);
function GetKeyValue(const Key: WideString): WideString;
public
// this works
property KeyValue[const Index: WideString] : WideString read GetKeyValue write SetKeyValue;
// this does not compile
// [Error]: Incompatible types: 'String' and 'Integer'
property Speed: WideString index 'SPEED' read GetKeyValue write SetKeyValue;
end;
Speed 属性给了我错误:
不兼容的类型:'String' 和 'Integer'
我需要索引是字符串。
是否可以将index 与字符串值一起使用?
【问题讨论】: