我正在尝试在 Powershell v5 中定义一个类,但我无法从类函数中访问变量。
前任。
PS C:\> class Foo{
$bar = 'foobar'
mymethod(){
$bar + '123'
}
}
PS C:\> [Foo]::new().mymethod()
PS C:\> At line:4 char:11
+ $bar + '123'
Variable is not assigned in the method.