Delphi(可能还有很多其他语言)有类助手。它们提供了一种向现有类添加额外方法的方法。无需创建子类。
那么,类助手有什么用处呢?
最佳答案
我正在使用它们:
- 至insert enumerators进入不实现它们的 VCL 类。
- 至enhance VCL 类。
向 TStrings 类添加方法,以便我可以在 my derived lists 中使用相同的方法。并在 TStringList 中。
TGpStringListHelper = class helper for TStringList public function Last: string; function Contains(const s: string): boolean; function FetchObject(const s: string): TObject; procedure Sort; procedure Remove(const s: string); end; { TGpStringListHelper }
简化对记录字段和 remove casting 的访问.
关于delphi - 类(class)助手有什么用处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/253399/