Appearance
类
class Person {
[string] $Name
[int] $Age
Person([string]$Name, [int]$Age) {
$this.Name = $Name
$this.Age = $Age
}
}
class People {
[string] $Name
[int] $Age
People([hashtable]$Info) {
switch ($Info.Keys) {
'Name' { $this.Name = $Info.Name }
'Age' { $this.Age = $Info.Age }
}
}
}
[Person]::new('David', 30)
[People]::new(@{
Name = 'Bob'
Age = 25
})| Name | Age |
|---|---|
| David | 30 |
| Bob | 25 |