Code, eat, sleep, repeat! Well, that's not exactly true.
I live in Hamburg with my beautiful wife. I work as a software engineer. In my free time I like to travel, making music, skiing & photography.
pretty handy extension. I've a library with many extension methods myself on github.com/iss0/jastExtensions. I have some methods which somehow solve the same problem, but afterwards cleaning up the list or dictionary:
/// <summary>/// Removes all elements from the collection which are null /// </summary>/// <typeparam name="T"></typeparam>/// <param name="source"></param>/// <returns></returns>publicstaticIEnumerable<T>NotNull<T>(thisIEnumerable<T>source){if(source==null){thrownewArgumentNullException(nameof(source));}returnsource.Where(t=>t!=null);}/// <summary>/// Removes every entry from the dictionary whose value is null/// </summary>/// <typeparam name="TKey"></typeparam>/// <typeparam name="TValue"></typeparam>/// <param name="dictionary"></param>/// <returns></returns>publicstaticIDictionary<TKey,TValue>ValueNotNull<TKey,TValue>(thisIDictionary<TKey,TValue>dictionary){if(dictionary==null){thrownewArgumentNullException(nameof(dictionary));}returndictionary.Where(pair=>pair.Value!=null).ToDictionary(pair=>pair.Key,pair=>pair.Value);}
These two methods are just a few I've found useful over time and are part of my library. Some limitations on extension methods will fall in future C# 8, see channel9.msdn.com/Blogs/Seth-Juare....
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey there,
pretty handy extension. I've a library with many extension methods myself on github.com/iss0/jastExtensions. I have some methods which somehow solve the same problem, but afterwards cleaning up the list or dictionary:
These two methods are just a few I've found useful over time and are part of my library. Some limitations on extension methods will fall in future C# 8, see channel9.msdn.com/Blogs/Seth-Juare....