Created
April 3, 2017 19:44
-
-
Save OhiraKyou/45c5e2c131827776ba53f847936288d4 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace OhiraKyou.Extensions { | |
public static class CollectionExtensions { | |
public static Dictionary<TKey, TValue> WithoutNullKeys<TKey, TValue> (this Dictionary<TKey, TValue> dictionary) { | |
return (from kv in dictionary | |
where kv.Value != null | |
select kv).ToDictionary(kv => kv.Key, kv => kv.Value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment