Why is there no Dictionary.TrimExcess()?

后端 未结 5 1527
醉梦人生
醉梦人生 2021-02-14 08:03

In .NET, there is a constructor for Dictionary that takes one parameter, int capacity. This is the same as with many other collecti

5条回答
  •  攒了一身酷
    2021-02-14 08:16

    By 2019, .Net Standard 2.1+ and .Net Core 2.1+ implement Dictionary.TrimExcess():

    see: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2.trimexcess?view=netstandard-2.1

    .Net Framework doesn't implement it in any version.

提交回复
热议问题