【发布时间】:2010-10-15 20:19:43
【问题描述】:
我正在尝试在 PowerShell 中声明 List,其中 Person 是使用 Add-Type 定义的:
add-type -Language CSharpVersion3 -TypeDefinition @"
public class Person
{
public Person() {}
public string First { get; set; }
public string Last { get; set; }
}
"@
这很好用:
New-Object Person
New-Object System.Collections.Generic.List``1[System.Object]
但是这条线失败了:
New-Object System.Collections.Generic.List``1[Person]
这里有什么问题?
【问题讨论】:
-
对于其他想知道的人来说,失败的行(上面)在 Powershell 3.0 中有效(尽管我需要删除“-Language CSharpVersion3”,因为我在 Windows Server 2012 上运行了它)。
标签: generics collections powershell