gpt4 book ai didi

c# - ImmutableArray 在哪里?

转载 作者:太空狗 更新时间:2023-10-29 22:36:54 25 4
gpt4 key购买 nike

为什么 ImmutableArray Microsoft Immutable Collections NuGet 包版本中似乎没有 1.0.34

enter image description here

最佳答案

ImmutableArray不存在于您的库版本中。

正如您在 version history 中看到的那样,1.1.20 的发行说明提到“重新包含 ImmutableArray

您可以在 .NET 博客的 1.0 版本中找到关于 ImmutableArray 为何缺失的解释,在此 announcement . (简而言之,当 Roslyn 团队尝试使用该类型而不是常规数组时,他们的性能受到了显着影响,负责该库的团队不确定如何解决该问题,同时保持合理的 API。)

您将在其新的 NuGet 包下找到该库的更新版本, System.Collections.Immutable .

注意:根据 source codeSystem.Collections.Immutable 的新版本中,他们显然已经决定接受 API 攻击——也就是说,对未初始化的 ImmutableArray 进行一些操作。会抛出一个令人惊讶的 NullReferenceException秒。显然,ImmutableArray不应该永远被实例化为new . (应改用 ImmutableArray<T>.Empty)

关于c# - ImmutableArray 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29273466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com