课堂助手有什么好用处? [英] What are good uses for class helpers?
本文介绍了课堂助手有什么好用处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
那么,类帮助器有什么好用?
解决方案 div>
我正在使用它们:
- To 将枚举器插入到不实现它们的VCL类中。 li>
- 要增强VCL类别。
-
要向TStrings类添加方法,因此我可以在我的派生列表和TStringList。
TGpStringListHelper =类帮助对于TStringList
public
函数Last:string;
function包含(const s:string):boolean;
函数FetchObject(const s:string):TObject;
程序排序;
程序删除(const s:string);
结束{TGpStringListHelper}
-
为了简化对记录字段的访问,删除投射。
Delphi (and probably a lot of other languages) has class helpers. These provide a way to add extra methods to an existing class. Without making a subclass.
So, what are good uses for class helpers?
解决方案
I'm using them:
- To insert enumerators into VCL classes that don't implement them.
- To enhance VCL classes.
To add methods to the TStrings class so I can use the same methods in my derived lists and in 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 }
To simplify access to record fields and remove casting.
这篇关于课堂助手有什么好用处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文