Skip to content

Instantly share code, notes, and snippets.

@OhiraKyou
Created April 3, 2017 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OhiraKyou/45c5e2c131827776ba53f847936288d4 to your computer and use it in GitHub Desktop.
Save OhiraKyou/45c5e2c131827776ba53f847936288d4 to your computer and use it in GitHub Desktop.
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