【问题标题】:Is there a difference between using Collections.Generic.List[Int] and Collections.Generic.List``1[Int] in PowerShell?在 PowerShell 中使用 Collections.Generic.List[Int] 和 Collections.Generic.List``1[Int] 有区别吗?
【发布时间】:2020-03-19 21:13:28
【问题描述】:

问题说明了一切。 PowerShell 中的Collections.Generic.List[Int]Collections.Generic.List``1[Int] 之间有区别吗?如果有,有什么区别?

例如,如果我使用$list = New-Object Collections.Generic.List``1[Int]

“``”和“1”背后的含义是什么?

如果这个问题已经被问过,那么我很抱歉。没找到。

【问题讨论】:

    标签: powershell


    【解决方案1】:

    它们是一样的:

    PS> [Collections.Generic.List[Int]] -eq [Collections.Generic.List``1[Int]]                                
    True
    

    后者就是该类型在 .NET Standard 库中的实际命名方式。泛型类型都有一个带有反引号和泛型类型参数数量的后缀。不过,大多数语言都对程序员隐藏了这一点。 PowerShell 仅在更高版本中获得了那些无后缀的泛型类型,所以我猜这两种变体仍然有效。

    【讨论】:

    • 感谢您的快速回答!我会在可以的时候标记它。
    猜你喜欢
    • 1970-01-01
    • 2018-08-26
    • 2021-05-03
    • 2015-01-06
    • 1970-01-01
    • 2010-11-18
    • 2016-08-23
    • 2017-02-23
    • 1970-01-01
    相关资源
    最近更新 更多