方法和屬性
class Person {
[string] $FirstName
[string] $LastName
[string] Greeting() {
return "Greetings, {0} {1}!" -f $this.FirstName, $this.LastName
}
}
$x = [Person]::new()
$x.FirstName = "Jane"
$x.LastName = "Doe"
$greeting = $x.Greeting() # "Greetings, Jane Doe!"