【发布时间】:2017-04-26 13:14:39
【问题描述】:
有人知道为什么下面的代码会引发内部 L2095 错误吗?
显然编译器有问题,字典的键是类类型。
有人知道解决方法吗?
(PS:当我不包含TestDict := TDictTest.Create; 部分或键不是类类型时,不会引发错误)
TTestClass = class
end;
TTypeOfTestClass = type of TTestClass;
TDictTest = TDictionary<TTypeOfTestClass,Integer>;
var
TestDict: TDictTest;
implementation
initialization
TestDict := TDictTest.Create;
TestDict.Free
回答后添加:
显然这是关于我本能地使用“type of”而不是“class of”。 “Type of”被编译器接受,因此会造成混淆。
引用与此相关的问题:What "type of" declaration represents in Delphi and how can it be used
【问题讨论】:
标签: delphi generics delphi-xe2