Horje
get all classes that extend a class c# Code Example
get all classes that extend a class c#
public static class ReflectiveEnumerator
{
    static ReflectiveEnumerator() { }

    public static IEnumerable<T> GetEnumerableOfType<T>(params object[] constructorArgs) where T : class, IComparable<T>
    {
        List<T> objects = new List<T>();
        foreach (Type type in 
            Assembly.GetAssembly(typeof(T)).GetTypes()
            .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
        {
            objects.Add((T)Activator.CreateInstance(type, constructorArgs));
        }
        objects.Sort();
        return objects;
    }
}




Csharp

Related
c# object to json string Code Example c# object to json string Code Example
get array from column datatable c# Code Example get array from column datatable c# Code Example
c# float Code Example c# float Code Example
how to write web service for API in c# Code Example how to write web service for API in c# Code Example
play tic tac toe Code Example play tic tac toe Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
15