Essential C# Reflection  Suggest an edit

Get a Type by name with namespace

To do this you need a reference to the assembly which contains the type. If you have another type available which you know is in the same assembly as the one you want you can do this:


Less efficient but more general is as follows:

Type t = null;
foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
    if (ass.FullName.StartsWith("System."))
    t = ass.GetType(typeName);
    if (t != null)

Notice the check to exclude scanning System namespace assemblies to speed up the search. If your type may actually be a CLR type, you will have to delete these two lines.

If you happen to have the fully assembly-qualified type name including the assembly you can simply get it with


Table Of Contents
22 Enum
62 Reflection
107 Stream
108 Timers
  ↑ ↓ to navigate     ↵ to select     Esc to close