You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell无法创建System.Collections.ArrayList对象的解决方案

问题

执行以下PowerShell代码创建ArrayList时报错:

[System.Collections.ArrayList]$list= @()
#list.Add($MonitorName);

错误提示:

Cannot convert value to type "System.Collections.ArrayList". Only core types are supported in this language mode.

解决方案

在语言约束模式下,可使用PowerShell原生数组实现列表功能,示例代码如下:

$list= @()
$list += "aaa"
$list += "bbb"

通过原生数组的+=操作符添加元素,无需依赖System.Collections.ArrayList这类非核心类型,可适配当前语言模式的限制。

内容的提问来源于stack exchange,提问作者Sravani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 05:19:53