1

How I can call a static class method from another static class method?

Class MyClass{

    static [String] Method1(){
        return "Hello";
    }

    static [String] Method2(){
        # Call another static method from the same class
        return  Method1() + "World"; 
    }

}

I have tried [MyClass]::Method1() but I wan to know if there is any shorter.

user
  • 19
  • 1
  • 4
    No that's it. Why would length matter? These are .net classes and methods and there are no shortcuts for such a language. Maybe provide some context into what are you looking for with "shorter". – Alex Sarafian Oct 07 '19 at 12:10
  • You can always wrap a static method call in a PowerShell function if you need it shortened for some reason. – Ansgar Wiechers Oct 07 '19 at 12:19
  • Does this answer your question? [Powershell: How to call a static method from the other static method](https://stackoverflow.com/questions/66322790/powershell-how-to-call-a-static-method-from-the-other-static-method) – Lance U. Matthews Feb 24 '22 at 06:07

0 Answers0