I have been working on a scripting project that involves creating custom powershell classes. I am currently trying to understand the following syntax
$Temp = [myclass[]]::new(1)
This syntax seems to create a generic List of some kind where I can specify the size of the List. Is there any way for me to modify the constructor for this? Ideally I would like to do something like the following:
And this would call the constructor for myclass for each of the items in $ClassData. Unfortunately this is not the way that it works currently and I have been working around the situation by using the following:
will meet the simple example that I used and calls the class constructor with the corresponding data from the $ClassData array. So powershell basically handles the foreach loop automatically using that syntax. I am still experimenting with calling more complex constructors
TypeName: MyClass
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Name Property string Name {get;set;}
Name
----
This
Is
A
Test