Advertisement
Guest User

LINQ Extensions Examples

a guest
Nov 1st, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1.         /// <summary>
  2.         /// Replaces a null reference with an empty collection.
  3.         /// </summary>
  4.         /// <typeparam name="T"></typeparam>
  5.         /// <param name="source">The collection reference.</param>
  6.         /// <returns>The collection or an empty one</returns>
  7.         public static IEnumerable<T> NullToEmpty<T>(this IEnumerable<T> source)
  8.         {
  9.             return source ?? Enumerable.Empty<T>();
  10.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement