如何在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