delphi - 类(class)助手有什么用处?

标签 delphi class helper

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/

相关文章:

c++ - 无法使用基类的方法

delphi - 在评估/修改 (Ctrl+F7) 窗口中调用辅助函数?

delphi - 有没有办法在 Delphi IDE 编辑器中更改默认生成的代码包装宽度?

delphi - CryptoAPI 返回 HMAC_SHA1 的错误结果

java - 与静态成员一起上课

java - 我可以使用 .getClass() == .class 或 .getClass() == .class.getClass() 吗?

asp.net-mvc - ServiceStack Funq MVC html 帮助程序扩展

javascript - 查找mongo文档中数组的最后一项并检查其字段是否为某个值

delphi - 为什么 Indy 10 会报告内存泄漏?

delphi - VC工程中调用Delphi函数