I am not to familar with powershell. I am trying to do something that would be a single line of code in C# but in powershell it is a pain :(
In the three lines below wow3 throws an error. Anyone know why wow3 throw a type not found error? Does this syntax for delegates only work for built in types?
$wow1 =[System.Action[int]]
$wow2 =[MyType]
$wow3 =[System.Action[MyType]]
This line of PowerShell:
$wow1 = [System.Action[int]]
is equal to this line of C#:
var d = typeof(System.Action<int>);
That is, $wow1
contains a System.RuntimeType
. Is that really what you are trying to do?
Perhaps you want something like this instead?
C:\PS> [Action[int]]$action = {param($i) Write-Host "i is $i"}
C:\PS> $action.Invoke(10)
i is 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With