Created
July 25, 2012 09:08
-
-
Save fresky/3175210 to your computer and use it in GitHub Desktop.
Extension method for c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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