Entwicklung_BLAZOR/InterneDLLs/LambertzEssentials/LamDictionary.cs
2025-08-23 19:30:21 +02:00

33 lines
896 B
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace De.Lambertz.Essentials
{
public class LamDictionary<K, T> : Dictionary<K, T>
{
/// <summary>
/// Erweitert das normale Dictionary um die Möglichkeit
/// ein Key-Value Paar hinzuzufügen und den (falls vorhanden)
/// bereits unter dem Schlüssel eingetragenen Value zurück zu
/// bekommen.
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public T AddReturnOld(K key,T value)
{
T result = default(T);
if (this.ContainsKey(key))
{
result = this[key];
this.Remove(key);
}
this.Add(key, value);
return result;
}
}
}