Horje
c# get all inherited classes of a class Code Example
c# get all inherited classes of a class
//through reflection
using System.Reflection;

//as a reusable method/function
Type[] GetInheritedClasses(Type MyType) 
{
  	//if you want the abstract classes drop the !TheType.IsAbstract but it is probably to instance so its a good idea to keep it.
	return Assembly.GetAssembly(MyType).GetTypes().Where(TheType => TheType.IsClass && !TheType.IsAbstract && TheType.IsSubclassOf(MyType));
}

//or as a selection of a type in code.
Type[] ChildClasses Assembly.GetAssembly(typeof(YourType)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(YourType))));

//Example of usage
foreach (Type Type in
                Assembly.GetAssembly(typeof(BaseView)).GetTypes()
                .Where(TheType => TheType.IsClass && !TheType.IsAbstract && TheType.IsSubclassOf(typeof(BaseView))))
            {

                AddView(Type.Name.Replace("View", ""), (BaseView)Activator.CreateInstance(Type));
            }




Csharp

Related
oncollisionenter unity Code Example oncollisionenter unity Code Example
unity create cube in script Code Example unity create cube in script Code Example
c# round number down Code Example c# round number down Code Example
c# how to add newline on text box Code Example c# how to add newline on text box Code Example
increase variable C# Code Example increase variable C# Code Example

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