是否可以使用两个记录助手的字符串类型? [英] Is it possible to use two record helpers for the string type?

查看:189
本文介绍了是否可以使用两个记录助手的字符串类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了这个帮助器,以便为字符串添加一些更多的功能类型:

I created this helper in order to add some more functions to the string type:

type
  AStringHelper = record helper for string
    function Invert: string; overload;
    function InvertMe: string; overload;
  end;

但是当我在代码中使用它时, TStringHelper System.StrUtils 出来,我不能使用它的功能。

But when I use it in my code, the TStringHelper in System.StrUtils "gets out" and I can't use it's functions.

是吗可能两者共存?

推荐答案

最多只有一个助手可以在您的代码中的任何一个位置处于活动状态。 文档说:

At most one helper can active at any one point in your code. The documentation says this:


您可以使用单个
类型来定义和关联多个助手。但是,只有零个或一个帮助器适用于源代码中的任何
特定位置。在
最近的范围内定义的帮助器将适用。类或记录助手范围是以正常的Delphi方式确定的
(例如,在单位的用法子句中留下的
)。

You can define and associate multiple helpers with a single type. However, only zero or one helper applies in any specific location in source code. The helper defined in the nearest scope will apply. Class or record helper scope is determined in the normal Delphi fashion (for example, right to left in the unit's uses clause).

由于记录助手不支持继承,除了重新实现标准助手的功能之外,没有办法同时兼容标准助手和助手的功能。

Since record helpers do not support inheritance, there's no way to have both the standard helper's and your helper's functionality active at the same time, other than re-implementing the standard helper's functionality.

这篇关于是否可以使用两个记录助手的字符串类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆