我如何在 Oxygene 中声明全局方法

发布于 2024-08-04 12:26:17 字数 175 浏览 1 评论 0原文

我如何使用 __Global 类在 delphi prism 中声明全局方法

并建议使用全局方法?

不幸的是我还没有找到任何例子。

How i can declare a global method in delphi prism using the __Global class?

And It is recommended to use global methods?

unfortunately I have not found any example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫瑾少女 2024-08-11 12:26:17

是的,如果您在项目选项中打开“允许全局”选项,则可以。那么你可以执行以下代码:

interface

method GlobalMethod: Integer; public;

implementation

不建议使用这种结构。更 .Net 的方法是在类上使用静态/类方法。

type
  TSomeClass = public class
  public
    class method GlobalMethod: Integer;
  end;

// Call like this
I := TSomeClass.GlobalMethod;

Yes, you can if you turn on the Allow Globals option in your project options. Then you can just do the following code:

interface

method GlobalMethod: Integer; public;

implementation

It is not recommended to use this construction. A more .Net way is to use a static/class method on a class.

type
  TSomeClass = public class
  public
    class method GlobalMethod: Integer;
  end;

// Call like this
I := TSomeClass.GlobalMethod;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文