|
RE: Problem Calling String(char[] value) constructor I was also playing aroudn to create a new string object through other
constructor with signature, "public String (char[] value, int startIndex, int
length)"
It was painfully tough to get around to pass arguments for startIndex and
Length...
Where, $a is an Character array of "Hello World" string.
[^_^]PS[148]>new-object String(,$a)
Hello World
[^_^]PS[149]>new-object String((,$a), 0, 5) #expecting "Hello"
New-Object : Cannot convert argument "0", with value: "System.Object[]", for
".
ctor" to type "System.Char[]": "Cannot convert "System.Char[]" to
"System.Char"
.."
At line:1 char:11
+ new-object <<<< String((,$a), 0, 5) #expecting "Hello"
[^_^]PS[150]>New-Object string (& { $OFS = ''; $p }) 0 5
New-Object : A parameter cannot be found that matches argument ''.
At line:1 char:42
+ New-Object string (& { $OFS = ''; $p }) 0 <<<< 5
# this works.
[^_^]PS[151]>New-Object string (& { $OFS = ''; $p }), 0, 5
Hello
I had actually expected "150"th command to work instead of 151st one though. |