英文:
how can I get the ClassType from a Class method?
问题
你可以使用 ClassName
方法来获取类的类型。以下是示例代码:
class function TSomething.MyClass: TClass;
begin
Result := Self;
end;
希望这有所帮助。
英文:
How do I return the type of a class in a class method?
In a regular method, I can use self.ClassType
, but there doesn't seem to be a class method on TObject that achieves this (although I can get the ClassName
).
class function TSomething.MyClass: TClass;
begin
//what goes here?
end;
答案1
得分: 3
In a class method the TClassType is just Self
class function TSomething.MyClass: TClass;
begin
result := Self;
end;
英文:
In a class method the TClassType is just Self
class function TSomething.MyClass: TClass;
begin
result := Self;
end;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论