【发布时间】:2022-10-19 20:07:55
【问题描述】:
作为List Class 的相互.Net 列表通常优于原生不可变PowerShell Array @() 以及:
-
PowerShell scripting performance considerations(由avoiding the increase assignment operator (
+=) to create a collection) - 复杂的(递归)函数,如Powershell filling array with function calling itself to loop through
不幸的是,这些类型在Constrained Language mode 中不可用
$ExecutionContext.SessionState.LanguageMode = 'ConstrainedLanguage'
$List = [Collections.Generic.List[object]]::new()
无效操作: 无法创建类型。此语言模式仅支持核心类型。
有没有办法解决这个问题?
【问题讨论】:
标签: list powershell