gpt4 book ai didi

c# - Microsoft.Bcl.Immutable : Create Dictionary based on IImmutableDictionary

转载 作者:太空宇宙 更新时间:2023-11-03 10:39:54 25 4
gpt4 key购买 nike

我在代码中获取 IDictionary 并需要返回 IImmutableDictionary。没问题,我只是运行扩展方法 ToImmutableDictionary()。

在其他地方,我得到了一个 IImmutableDictionary 并且需要返回一个 IDictionary。有这样做的首选方法吗?

最佳答案

像这样使用 imutable.ToDictionary(r=> r.Key, r=> r.Value):

Dictionary<int,int> dictionary = new Dictionary<int, int>();
IImmutableDictionary<int, int> imutable = dictionary.ToImmutableDictionary();
IDictionary<int, int> dictionary2 = imutable.ToDictionary(r=> r.Key, r=> r.Value);

关于c# - Microsoft.Bcl.Immutable : Create Dictionary based on IImmutableDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25789881/

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