C# get all child classes of a class
C#
//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));
}
Also in C#:
- Title
- c# region tag
- Category
- C#
- Title
- c# check if string is only letters and numbers
- Category
- C#
- Title
- replace all ponctuation characters c#
- Category
- C#
- Title
- c# find duplicates in list of strings
- Category
- C#
- Title
- unity variable from another script
- Category
- C#
- Title
- Assets\playermove.cs(30,37): error CS1003: Syntax error, ',' expected
- Category
- C#
- Title
- length of a string c#
- Category
- C#
- Title
- unity jump
- Category
- C#
- Title
- unity making homing rocket
- Category
- C#
- Title
- unity rotate around axis
- Category
- C#
- Title
- chase object unity
- Category
- C#
- Title
- start a particle effect when a button is pushed
- Category
- C#
- Title
- unity create a child object
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- datatable return column names
- Category
- C#
- Title
- unity gizmo draw line
- Category
- C#
- Title
- clear combobox c#
- Category
- C#
- Title
- how to make an array in csharp
- Category
- C#
- Title
- convert generic to type c#
- Category
- C#
- Title
- c# making a folder
- Category
- C#
- Title
- call a function c#
- Category
- C#
- Title
- nullreferenceexception c#
- Category
- C#
- Title
- c# foreach namevaluecollection
- Category
- C#
- Title
- weakreference tryget c#
- Category
- C#
- Title
- how to convert iformfile to byte array c#
- Category
- C#
- Title
- c# read char
- Category
- C#
- Title
- unity get all by tag
- Category
- C#
- Title
- c# for loop without increment
- Category
- C#
- Title
- c# loop
- Category
- C#
- Title
- unity transfoprm position y change
- Category
- C#
- Title
- resize image c#
- Category
- C#
- Title
- unity rotate object relative to camera
- Category
- C#
- Title
- unity how to move an object to another object
- Category
- C#
- Title
- built in methods to order a list c#
- Category
- C#
- Title
- how to add movement in unity
- Category
- C#
- Title
- unity make a int arry with preset values
- Category
- C#
- Title
- c# get enum value from string
- Category
- C#
- Title
- httpcontext in .net standard
- Category
- C#
- Title
- change partial view based on select asp.net core
- Category
- C#
- Title
- c# read a webpage data
- Category
- C#
- Title
- if entity.is Transient() Update Mvc 5 c#
- Category
- C#
- Title
- unity pro version free download
- Category
- C#
- Title
- how to move towards an object unity
- Category
- C#
- Title
- c# System.Resources.MissingManifestResourceException error
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- block wapalyzer from detecting codeigniter
- Category
- C#
- Title
- bitmap to byte array c#
- Category
- C#
- Title
- order by C#
- Category
- C#
- Title
- 5 second timer in c#
- Category
- C#
- Title
- how to create a variable in C#
- Category
- C#
- Title
- how to destroy a gameobject after some hits in unity 3d
- Category
- C#
- Title
- condition when a animation finishes in unity
- Category
- C#
- Title
- unity c# get bool from another script
- Category
- C#
- Title
- c# getasync response
- Category
- C#
- Title
- vb.net drag window without titlebar
- Category
- C#
- Title
- how to create a list in c# unity
- Category
- C#
- Title
- instantiate object in circle
- Category
- C#
- Title
- hot to move pobject unity
- Category
- C#
- Title
- c# iterate over string
- Category
- C#
- Title
- rotatearound unity
- Category
- C#
- Title
- matplotlib measure the width of text
- Category
- C#
- Title
- check distance to gameobject
- Category
- C#
- Title
- C# public 2d array
- Category
- C#
- Title
- in unity i want to destroy a gameobject when it hits the edge of the screen
- Category
- C#
- Title
- binding c#
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- c# catch two exceptions in one block
- Category
- C#
- Title
- C# foreach loop async but wait at end
- Category
- C#
- Title
- example HttpClient c# Post
- Category
- C#
- Title
- defining vectors in c#
- Category
- C#
- Title
- unity set list of strings
- Category
- C#
- Title
- unity random float
- Category
- C#
- Title
- c# get enum in list
- Category
- C#
- Title
- c# stop loop
- Category
- C#
- Title
- parse strings into words C#
- Category
- C#
- Title
- c# double question mark
- Category
- C#
- Title
- c# checksum
- Category
- C#
- Title
- convert string to double c#
- Category
- C#
- Title
- c# keyboard enter
- Category
- C#
- Title
- C# function return datareader
- Category
- C#
- Title
- c# create new thread
- Category
- C#
- Title
- How do i destroy a prefab without the error?
- Category
- C#
- Title
- C# webclient submit form
- Category
- C#
- Title
- c# print to console
- Category
- C#
- Title
- string to enum c#
- Category
- C#
- Title
- how to parse a string to an integer c#
- Category
- C#
- Title
- how to convert a number to 2 decimal places in c#
- Category
- C#
- Title
- how do i limit the amount of prefabs in unity using c# script
- Category
- C#
- Title
- c# how to open file explorer
- Category
- C#
- Title
- how to add system.messaging c#
- Category
- C#
- Title
- unity how to get y value
- Category
- C#
- Title
- unity move character
- Category
- C#
- Title
- max of array C#
- Category
- C#
- Title
- winforms c# add data to datagridview with a button
- Category
- C#
- Title
- c# filter non alphanumeric characters
- Category
- C#
- Title
- c# create dynamic object
- Category
- C#
- Title
- how to change an int value c#
- Category
- C#
- Title
- exit game unity
- Category
- C#
- Title
- c# filesystemwatcher double events
- Category
- C#