Print Types : Type : Reflection C# Source Code


Custom Search

C# Source Code » Reflection » Type »

 

Print Types








    
 
using System;
using System.Collections;
using System.Reflection;

public class MainClass{
    public static void Main(){
        Assembly LoadedAsm = Assembly.LoadFrom("yourName");
        Console.WriteLine(LoadedAsm.FullName);
        Type[] LoadedTypes = LoadedAsm.GetTypes();
        if (LoadedTypes.Length == 0) {
            Console.WriteLine("No Types!");
        } else {
            foreach (Type t in LoadedTypes) {
                if (t.IsPublic) {
                    Console.WriteLine("Public ");
                } else if (t.IsNestedPublic) {
                    Console.WriteLine("Public Nested ");
                } else {
                    Console.WriteLine("Not Public ");
                }
                if (t.IsEnum) {
                    Console.WriteLine("Enum: ");
                } else if (t.IsValueType) {
                    Console.WriteLine("Struct: ");
                } else {
                    Console.WriteLine("Class: ");
                }
                Console.WriteLine("{0}", t.FullName);
            }
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Reflection
» Type