如何在PowerShell中创建长度为$ Count的char数组?如何在PowerShell中创建可变长度的char数组?
PS C:\Users\Administrator> $Count
415
PS C:\Users\Administrator> $chars = New-Object System.Char ($Count)
New-Object : Constructor not found. Cannot find an appropriate constructor for type System.Char.
At line:1 char:10
+ $chars = New-Object System.Char ($Count)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand
I tried
[Char[]] $chars = @(415)
我有一个类需要一个字符数组,但我基本上通过使用字符串找到了解决方案。但我只想问一下,是否有人知道如何创建一个长度可变的空字符数组。
例如:我如何在PowerShell中做到这一点? C# - > var chars = new Char [Count];
可能重复[如何在Powershell中填充一个未知长度的数组?)(http://stackoverflow.com/questions/12860830/how-do-i-populate-an-array-of-unkown-length-in-powershell) – TessellatingHeckler