using System; using System.Reflection; public class Program { public static void Main() { Assembly assembly = Assembly.GetExecutingAssembly(); // Get the current assembly Type[] types = assembly.GetTypes(); // Get all types in the assembly foreach(Type t in types) Console.WriteLine(t.Name); } }
using System; using System.Reflection; public class Program { public static void Main() { Assembly assembly = Assembly.GetExecutingAssembly(); Type[] types = assembly.GetTypes(); foreach(Type t in types) { if(t.BaseType == typeof(MyBaseClass)) // Check if type inherits from MyBaseClass Console.WriteLine(t.Name); } } }This code gets all the types in the current assembly that inherit from MyBaseClass and prints their names to the console. In conclusion, the System.Reflection module belongs to the System.Reflection package library in C#. The GetTypes() method is a powerful tool that allows you to get all the types in an assembly or filter them based on specific criteria.