Skip to content

Instantly share code, notes, and snippets.

@fresky
Created July 25, 2012 09:08
Show Gist options
  • Save fresky/3175210 to your computer and use it in GitHub Desktop.
Save fresky/3175210 to your computer and use it in GitHub Desktop.
Extension method for c#
public static class Extention
{
public static bool IsAbstrct(this Type type)
{
return type.IsAbstract;
}
public static bool IsEnumerableType(this Type t)
{
return typeof(IEnumerable<string>).IsAssignableFrom(t);
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(typeof (string).IsAbstrct());
Console.WriteLine(typeof(string).IsEnumerableType());
Console.WriteLine(typeof(List<string>).IsAbstrct());
Console.WriteLine(typeof(List<string>).IsEnumerableType());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment