c# get all inherited 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
- csharp create array list
- Category
- C#
- Title
- c# arrays of arrays
- Category
- C#
- Title
- c# convert double to int
- Category
- C#
- Title
- c list add element
- Category
- C#
- Title
- json serialize object capitalization config
- Category
- C#
- Title
- c# get full URL of page
- Category
- C#
- Title
- perlin noise unity
- Category
- C#
- Title
- how to declare variables in c#
- Category
- C#
- Title
- c# odd even median
- Category
- C#
- Title
- how to delay something in c# unity
- Category
- C#
- Title
- comments unity c#
- Category
- C#
- Title
- wpf binding ancestor codebehind
- Category
- C#
- Title
- 2D follow ia unity 2D with agrorange
- Category
- C#
- Title
- c# error "The name 'ViewBag' does not exist in the current context"
- Category
- C#
- Title
- c# window instantly close
- Category
- C#
- Title
- get setter c# model
- Category
- C#
- Title
- value is null to insert in c#
- Category
- C#
- Title
- asp net identity include phone number when registering
- Category
- C#
- Title
- unity check tag
- Category
- C#
- Title
- or in unity
- Category
- C#
- Title
- how to get value from object in c#
- Category
- C#
- Title
- bulk update in c# using jquery datatble
- Category
- C#
- Title
- c# shorten an definition
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- c# interview questions
- Category
- C#
- Title
- how to use variables in c#
- Category
- C#
- Title
- how to edit a c# list
- Category
- C#
- Title
- get set c#
- Category
- C#
- Title
- convert int to double c#
- Category
- C#
- Title
- .net loop through dictionary
- Category
- C#
- Title
- c# checksum
- Category
- C#
- Title
- how to raycast unit
- Category
- C#
- Title
- C# .net core convert int to enum
- Category
- C#
- Title
- how to close a form c#
- Category
- C#
- Title
- find negative version of integer in c#
- Category
- C#
- Title
- read in multiple numbers c#
- Category
- C#
- Title
- transform.Translate movement
- Category
- C#
- Title
- c# global enumerator
- Category
- C#
- Title
- unity round
- Category
- C#
- Title
- c# while loop
- Category
- C#
- Title
- c# rsa example
- Category
- C#
- Title
- initialise icollection c#
- Category
- C#
- Title
- IEnumerator
- Category
- C#
- Title
- c# add object to array
- Category
- C#
- Title
- 2d character controller unity
- Category
- C#
- Title
- c# float to string
- Category
- C#
- Title
- example HttpClient c# Post
- Category
- C#
- Title
- unity get max occurrence in list
- Category
- C#
- Title
- unity add component
- Category
- C#
- Title
- autofixture ignore property
- Category
- C#
- Title
- Linq - Random Elements
- Category
- C#
- Title
- how to change the title of the console in c#
- Category
- C#
- Title
- create a file in the directory of the exe and write to it c#
- Category
- C#
- Title
- beard styles without mustache Intitle:work with me
- Category
- C#
- Title
- c# mixed multidimensional array
- Category
- C#
- Title
- c# reverse a string
- Category
- C#
- Title
- unity round vector 3 to nearest integer
- Category
- C#
- Title
- unity position ui element
- Category
- C#
- Title
- how to sort string array alphabetically in c#
- Category
- C#
- Title
- create new object from generic c#
- Category
- C#
- Title
- c# creating exceptions
- Category
- C#
- Title
- what is c# used for
- Category
- C#
- Title
- c sharp check if key in dictionary
- Category
- C#
- Title
- toggle unity c#
- Category
- C#
- Title
- c# zip a file
- Category
- C#
- Title
- find mongodb c# with task T
- Category
- C#
- Title
- south african id number validation c#
- Category
- C#
- Title
- unity access child
- Category
- C#
- Title
- to list c#
- Category
- C#
- Title
- c# bitmap to Image
- Category
- C#
- Title
- count the number of notes in a given amount c#
- Category
- C#
- Title
- c# create new thread
- Category
- C#
- Title
- how to insert <input> datatype <td> in asp.net core table
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- how to initiate a varaible in cs
- Category
- C#
- Title
- how to trigger event when a com device is connected in c#
- Category
- C#
- Title
- unity monobehaviour
- Category
- C#
- Title
- unity up arrow input
- Category
- C#
- Title
- iframe set html content c#
- Category
- C#
- Title
- creating a c# class
- Category
- C#
- Title
- Length = '((System.Net.RequestStream)RequestStream).Length' threw an exception of type 'System.NotSupportedException'
- Category
- C#
- Title
- c# MD5.Create returning nul
- Category
- C#
- Title
- check if multiple variables are null c#
- Category
- C#
- Title
- Unity C# make object face away
- Category
- C#
- Title
- asp.net get query string parameter
- Category
- C#
- Title
- csharp check if env is development
- Category
- C#
- Title
- unity how to check object position
- Category
- C#
- Title
- unity variable from another script
- Category
- C#
- Title
- how to access first child of parent unity
- Category
- C#
- Title
- as c#
- Category
- C#
- Title
- c# request run as administrator
- Category
- C#
- Title
- httpcontext in .net standard
- Category
- C#
- Title
- F# convert generic.List to list
- Category
- C#
- Title
- entity framework core
- Category
- C#
- Title
- c# expandoobject indexer
- Category
- C#
- Title
- csharp first element of array
- Category
- C#
- Title
- how to hide and show object in unity script
- Category
- C#
- Title
- bash if null or empty
- Category
- C#
- Title
- convert from xls to xlsx C#
- Category
- C#
- Title
- c# get motherboard id
- Category
- C#