【问题标题】:How i can declare a global method in Oxygene我如何在 Oxygene 中声明一个全局方法
【发布时间】:2009-09-10 05:26:09
【问题描述】:

我如何declare a global method in delphi prism 使用 __Global 类?

并且推荐使用全局方法?

很遗憾,我没有找到任何示例。

【问题讨论】:

    标签: delphi-prism oxygene


    【解决方案1】:

    是的,如果您在项目选项中打开“允许全局变量”选项,则可以。然后你可以做以下代码:

    interface
    
    method GlobalMethod: Integer; public;
    
    implementation
    

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

    type
      TSomeClass = public class
      public
        class method GlobalMethod: Integer;
      end;
    
    // Call like this
    I := TSomeClass.GlobalMethod;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      • 1970-01-01
      • 2011-03-22
      • 2011-02-12
      • 2012-11-11
      相关资源
      最近更新 更多