Files
MQTTnet/MQTT.NET.Core/DictionaryExtensions.cs
T
2017-03-19 18:41:29 +01:00

22 lines
524 B
C#

using System;
using System.Collections.Generic;
namespace MQTTnet.Core
{
public static class DictionaryExtensions
{
public static TValue Take<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
{
if (dictionary == null) throw new ArgumentNullException(nameof(dictionary));
TValue value;
if (dictionary.TryGetValue(key, out value))
{
dictionary.Remove(key);
}
return value;
}
}
}