Mike Bridge bridgecanada _ com>
2006-10-06 20:08:02 UTC
Hi-
I was trying to instantiate some .Net objects from PowerShell, and I am
confused about why this happens when I pass an array to the constructor:
PS [Scripts] > $bytes=@([System.Text.Encoding]::UTF8.GetBytes("Hello
There"))
PS [Scripts] > new-object System.IO.MemoryStream($bytes)
New-Object : Cannot find an overload for ".ctor" and the argument count: "11".
At line:1 char:11
+ new-object <<<< System.IO.MemoryStream($bytes)
I see that this will work if I do this:
PS [Scripts] > new-object System.IO.MemoryStream(,$bytes)
However, I don't understand why my byte array of length 11 is getting passed
as 11 parameters instead of as an array. Does anyone know why this happens?
Is this the correct way to do this?
Thanks!
-Mike
I was trying to instantiate some .Net objects from PowerShell, and I am
confused about why this happens when I pass an array to the constructor:
PS [Scripts] > $bytes=@([System.Text.Encoding]::UTF8.GetBytes("Hello
There"))
PS [Scripts] > new-object System.IO.MemoryStream($bytes)
New-Object : Cannot find an overload for ".ctor" and the argument count: "11".
At line:1 char:11
+ new-object <<<< System.IO.MemoryStream($bytes)
I see that this will work if I do this:
PS [Scripts] > new-object System.IO.MemoryStream(,$bytes)
However, I don't understand why my byte array of length 11 is getting passed
as 11 parameters instead of as an array. Does anyone know why this happens?
Is this the correct way to do this?
Thanks!
-Mike