Created
June 19, 2012 10:23
-
-
Save kmorcinek/2953411 to your computer and use it in GitHub Desktop.
Extension methods for generic Dictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace KMorcinek.Common | |
{ | |
public static class DictionaryExtensions | |
{ | |
public static void IncrementAt<T>(this Dictionary<T, int> dictionary, T index) | |
{ | |
int count = 0; | |
dictionary.TryGetValue(index, out count); | |
dictionary[index] = ++count; | |
} | |
} | |
} | |
var newDic = oldDic.ToDictionary(x => x.Value, x => x.Key); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment