How to determine if object is of type IEnumerable
Code:
namespace NS {
class Program {
static IEnumerable GetInts()
How to determine if object is of type IEnumerable
?
Please feel free to use this fine, ultra small, generic extension method to determine if any object implements IEnumerable interface. It extends the Object type, so you can execute it using any instance of any object you're using.
public static class CollectionTestClass
{
public static Boolean IsEnumerable(this Object testedObject)
{
return (testedObject is IEnumerable);
}
}