using System; namespace SampleApplication { class Program { static void Main(string[] args) { // Get the types in the current assembly Type[] types = System.Reflection.Assembly .GetExecutingAssembly() .GetTypes(); // Print the name of each type foreach (Type type in types) { Console.WriteLine(type.Name); } } } }
using System; using System.IO; namespace SampleApplication { class Program { static void Main(string[] args) { // Get the types defined in System.dll assembly Type[] types = typeof(System.Console).Assembly .GetTypes(); // Create a file to store the names of the types using (StreamWriter writer = new StreamWriter("types.txt")) { // Write the name of each type to the file foreach (Type type in types) { writer.WriteLine(type.Name); } } } } }This example retrieves all the types defined in the System.dll assembly (which includes the Console class) and writes their names to a file. Package library: System.Reflection, System.IO