Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Replaces a null reference with an empty collection.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="source">The collection reference.</param>
- /// <returns>The collection or an empty one</returns>
- public static IEnumerable<T> NullToEmpty<T>(this IEnumerable<T> source)
- {
- return source ?? Enumerable.Empty<T>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement