The Static modifier

All of the members demonstrated so far have required creation of an instance of a type using either New-Object or ::new().

Static members may be executed without creating an instance of a type (based on a class).

Classes may implement static properties and static methods using the Static modifier keyword:

class MyClass {
static [String] $Property = 'Property value'
static [String] Method() {
return 'Method return'
}
}

The static members are invoked as follows:

[MyClass]::Property
[MyClass]::Method()

The Hidden modifier may be used in conjunction with the Static modifier. The modifiers may be used in either order.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.216.174