$sumList= New-Object System.Collections.Generic.List[int]
$eventList = New-Object System.Collections.Generic.List[string]
$preSumList= New-Object System.Collections.Generic.List[int]
$threadInitDelay = [int]$commaSplit[++$eventIndex].Split(':')[1].Trim()
$preProcessTime = [int]$commaSplit[++$eventIndex].Split(':')[1].Trim()+[int]$commaSplit[++$eventIndex].Split(':')[1].Trim()+$commaSplit[[int]++$eventIndex].Split(':')[1].Trim()
$respTime = [int]$commaSplit[++$eventIndex].Split(':')[1].Trim();
$index =$eventList.FindIndex({param([string]$s) return $s -like 'hi'})
if($index -eq -1){
$eventList.Add($eventName)
$sumList.Add($threadInitDelay)
$respSumList.Add($respTime)
收到此错误:显示错误,而在中的powershell列表添加元素[INT]?
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:151 char:19
+ $sumList.Add <<<< ($threadInitDelay)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:152 char:23
+ $respSumList.Add <<<< ($respTime)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:153 char:23
+ $respMaxTime.Add <<<< ($respTime)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:155 char:19
+ $minTime.Add <<<< ($threadInitDelay)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
能否请你帮我吗?
什么是那些变量的类型?我的意思是用'$ sumList.GetType()。FullName'来检查它。我可以看到你的代码,但如果你有一个开放的会话,这些变量被转换成不同的方式,他们不会工作。重新启动会话或打开新的控制台并再次测试以确保安全。 Mathis在另一个问题中建议你使用'remove-variable'。 '$ sumList =新物体System.Collections.Generic.List [INT]; $ sumList.Add(5)'为我工作。错误中的类型看起来不正确。 – Matt
这可能是一个愚蠢的目标。 http://stackoverflow.com/questions/27830659/same-input-into-mathround-returns-different-results/27873156#27873156。如果我对演员问题是正确的,那么答案就是解释问题。 – Matt
感谢man..got答案 –