Remove from Dictionary by Key and Retrieve Value

后端 未结 6 485
广开言路
广开言路 2020-12-17 20:05

Is there a way to remove an entry from a Dictionary (by Key) AND retrieve it\'s Value in \"the same step?\"

For example, I\'m

6条回答
  •  抹茶落季
    2020-12-17 20:44

    Starting with .NET Core 2.0, we have:

    public bool Remove (TKey key, out TValue value);

    https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2.remove?view=netcore-2.0#System_Collections_Generic_Dictionary_2_Remove__0__1__

    Note this API hasn't been included in .NET Standard 2.0 and .NET Framework 4.7.

提交回复
热议问题