Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# get all classes derived from type

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

            return objects;
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to pass id from view to controller in asp.net core 
Csharp :: adding a dependency injection service in windows forms app 
Csharp :: autofac .net core 6 
Csharp :: selenium scroll to element c# 
Csharp :: unity2d movement 
Csharp :: should i learn c # 
Csharp :: Get Last Access Time Of Directory C# 
Csharp :: c# modify dictionary in loop 
Csharp :: pause unity game 
Csharp :: disabling a button if textbox is empty c# 
Csharp :: c# chunk array linq 
Csharp :: c# show list in richtextbox 
Csharp :: how to turn on/off Particle System unity 
Csharp :: razor concatonate inline 
Csharp :: create new object c# 
Csharp :: unity rigidbody2d disable 
Csharp :: distance between two objects unity 2d 
Csharp :: ??= mean C# 
Csharp :: finding values in the registry 
Csharp :: c# list remove by index 
Csharp :: Printing pattern in c# 
Csharp :: how to access asp button of gridview 
Csharp :: deactivate a gameobject unity 
Csharp :: push c# array 
Csharp :: unitry raycast 
Csharp :: linq c# object except two lists 
Csharp :: ontriggerenter2d 
Csharp :: Get Mouse World Position 
Csharp :: Getting the text from a drop-down box 
Csharp :: C# http post request with file 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =