Forum Discussion
ahinterl
Jul 02, 2025Brass Contributor
Array and array member methods
The following PowerShell code: class MyClass { }
class MyClass1 : MyClass {
[void] OutMsg([string] $Str) {
Write-Host -Object "MyClass1: $Str"
}
}
class MyClass2 : MyClass {
[vo...
Andres-Bohren
Jul 02, 2025Iron Contributor
HI ahinterl​
Let's check without an Array
class MyClass { }
class MyClass1 : MyClass {
[void] OutMsg([string] $Str) {
Write-Host -Object "MyClass1: $Str"
}
}
[MyClass[]] $DemoClass = [MyClass1]::new()
$DemoClass | gm
TypeName: MyClass1
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
OutMsg Method void OutMsg(string Str)
ToString Method string ToString()
If it is an Array you have to select the Item (or i think of a Line in a Spreadsheet) with [item]
class MyClass { }
class MyClass1 : MyClass {
[void] OutMsg([string] $Str) {
Write-Host -Object "MyClass1: $Str"
}
}
class MyClass2 : MyClass {
[void] OutMsg([string] $Str) {
Write-Host -Object "MyClass2: $Str"
}
}
[MyClass[]] $ClassArray = @([MyClass1]::new(),[MyClass1]::new())
$ClassArray[0] | gm
TypeName: MyClass1
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
OutMsg Method void OutMsg(string Str)
ToString Method string ToString()It's all there :)
Kind Regards
Andres