To assign a value to a static member using a dot-sourced file, follow these steps:
Example:
# MyScript.ps1
class MyClass {
static $MyStaticMember
}
Example:
. .\MyScript.ps1
Example:
MyClass::$MyStaticMember = "Hello, world!"
Example:
Write-Host MyClass::$MyStaticMember
This will output "Hello, world!" to the console.
Asked: 2023-07-20 17:55:18 +0000
Seen: 15 times
Last updated: Jul 20 '23