6

我有以下情况:

TMyFormClass = class of TMyForm

function IsMyClass(AClass: TFormClass);
begin
  Result := AClass is TMyForm      // Operator not applicable to this operand type
  Result := AClass is TMyFormClass // Operator not applicable to this operand type
end;

这两行都没有构建,错误是Operator not applicable to this operand type

我该怎么做这个比较?

4

1 回答 1

10

运算符的 lhsis应该是一个实例,但是您提供了一个类。

你需要的是InheritsFrom类方法:

AClass.InheritsFrom(TMyForm);
于 2019-11-11T19:29:03.090 回答