Question

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.

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top