Skip to content

Instantly share code, notes, and snippets.

@aivascu
Created June 20, 2015 12:48
Show Gist options
  • Save aivascu/305fe85be9de847c23f6 to your computer and use it in GitHub Desktop.
Save aivascu/305fe85be9de847c23f6 to your computer and use it in GitHub Desktop.
LINQ independent IsNullOrEmpty extension class
using System.Collections;
using System.Collections.Generic;
namespace Demo.Utility
{
public static class IsNullOrEmptyExtension
{
public static bool IsNullOrEmpty(this IEnumerable source)
{
if (source != null)
{
foreach (object obj in source)
{
return false;
}
}
return true;
}
public static bool IsNullOrEmpty<T>(this IEnumerable<T> source)
{
if (source != null)
{
foreach (T obj in source)
{
return false;
}
}
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment