elena1234

Collection Extensions

Mar 24th, 2021 (edited)
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. public static class CollectionExtensions
  2. {
  3.    public static bool IsEmpty<T>(this ICollection<T> collection) // say what you want to extension
  4.     {
  5.       return collection.Count = 0;
  6.     }
  7.  
  8.    public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> values)
  9.     {
  10.       foreach(T value in values)
  11.        {
  12.          collection.Add(value);
  13.        }
  14.     }
  15.        // And now every ICollection has these both methods
  16. }
  17.  
Add Comment
Please, Sign In to add comment