METHOD
Dictionary<TKey,TValue>.Remove (TKey, out TValue)
Removes a key and reports whether it existed; when successful the removed value is returned. Ordinary dictionaries do not make concurrent compensation or durable state updates atomic.
Formal Syntax & Structure
csharp syntaxcsharp
map.Remove(key,out var value)Working Example
Example Snippetcsharp
using System;using System.Collections.Generic;using System.Threading;using System.Threading.Tasks;using System.Threading.Channels;var map=new Dictionary<string,int>{{"R1",2}}; Console.WriteLine(map.Remove("R1",out int units)&&units==2); // True