PageRenderTime 71ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/opensource/extensions/system.collections/collection/IsNullOrEmpty.cs

http://zielonka.codeplex.com
C# | 25 lines | 15 code | 2 blank | 8 comment | 3 complexity | b9e9c80fbe9d047dddd7220ab25d1ee5 MD5 | raw file
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace zielonka.co.uk.extensions.system.collections
  7. {
  8. /*
  9. Works with collections and arrays:
  10. bool isNullOrEmpty = array.IsNullOrEmpty()
  11. instead of
  12. bool isNullOrEmpty = array == null || array.Length == 0;
  13. */
  14. public static partial class CollectionExtensions
  15. {
  16. public static bool IsNullOrEmpty(this ICollection obj)
  17. {
  18. return (obj == null || obj.Count == 0);
  19. }
  20. }
  21. }