1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
using System;
using System.Collections.Generic;
using System.Text;
namespace mein.namespacedings
{
public class DictionaryPlus<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;
}
}
}
|