Created
October 24, 2017 20:04
-
-
Save jsauve/17cab7d3379348c3141c8395a19da12a to your computer and use it in GitHub Desktop.
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
private static IEnumerable<KeyValuePair<TKey,TValue>> RemoveByKey<TKey,TValue>( | |
this IEnumerable<KeyValuePair<TKey,TValue>> pairs, | |
string key) | |
{ | |
var index = pairs.Select(x => x.Key).ToList().FindIndex(x => x.Equals(key)); | |
if (index >= 0) | |
{ | |
var result = pairs.ToList(); | |
result.RemoveAt(index); | |
return result; | |
} | |
return pairs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment