【发布时间】:2016-01-28 15:38:08
【问题描述】:
我正在尝试使用 powershell 脚本从数组列表中查找元素的索引,但是得到以下给定的错误
方法调用失败,因为 [System.String[]] 不包含 名为“IndexOf”的方法。
使用的代码:
[String[]]$eventList = New-Object System.Collections.ArrayList
$eventList.GetType().FullName
$index = $eventList.IndexOf('cvv');
【问题讨论】:
-
在这种情况下什么是“cvv”?
-
遗憾的是,我认为 powershell 数组不支持
IndexOf。 -
'cvv' 是我试图在 $eventList 中找到的一个字符串,它是 null 事情是我想要 $eventList null 中的 'cvv' 的位置它应该返回 '-1' 但它是返回错误
标签: powershell powershell-2.0 powershell-3.0