How to declare a static member in a Powershell 5 class? How to declare a static member in a Powershell 5 class? powershell powershell

How to declare a static member in a Powershell 5 class?


PowerShell 5 added a static keyword for this:

static [string] $Bar = 'static member'

Demo:

PS > class Foo {>>     static [string] $Bar = 'static member'>> }   PS > [Foo]::Barstatic memberPS >