Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Assembly.GetType Method (String)

Gets the Type object with the specified name in the assembly instance.

Namespace:  System.Reflection
Assemblies:   mscorlib (in mscorlib.dll)
  System.Reflection (in System.Reflection.dll)

public virtual Type GetType(
	string name


Type: System.String

The full name of the type.

Return Value

Type: System.Type
An object that represents the specified class, or null if the class is not found.




name is invalid.


name is null.


name requires a dependent assembly that could not be found.


In the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, IOException, instead.

name requires a dependent assembly that was found but could not be loaded.


The current assembly was loaded into the reflection-only context, and name requires a dependent assembly that was not preloaded.


name requires a dependent assembly, but the file is not a valid assembly.


name requires a dependent assembly which was compiled for a version of the runtime later than the currently loaded version.

This method only searches the current assembly instance. The name parameter includes the namespace but not the assembly. To search other assemblies for a type, use the Type.GetType(String) method overload, which can optionally include an assembly display name as part of the type name.


If the type has been forwarded to another assembly, it is still returned by this method. For information on type forwarding, see Type Forwarding in the Common Language Runtime.

The following example defines an abstract MeansOfTransportation class in the Transportation namespace. It calls the GetType(String) method to retrieve its Type object, calls the Type.GetProperties method to get an array of PropertyInfo objects that represent the type's properties, and then displays information on the type's abstract properties. Note that the call to the GetType(String) method uses the type's fully qualified name (that is, its namespace along with its type name).

using System;
using System.Reflection;

public class Example
   public static void Main()
      Assembly assem = typeof(Example).Assembly;
      Type t = assem.GetType("Transportation.MeansOfTransportation");
      if (t != null) {
         Console.WriteLine("Virtual properties in type {0}:", 
         PropertyInfo[] props = t.GetProperties();
         int nVirtual = 0;
         for (int ctr = 0; ctr < props.Length; ctr++)
            if (props[ctr].GetMethod.IsVirtual) {
               Console.WriteLine("   {0} (type {1})",

         if (nVirtual == 0) 
            Console.WriteLine("   No virtual properties");

namespace Transportation
   public abstract class MeansOfTransportation
      abstract public bool HasWheels { get; set; }
      abstract public int Wheels { get; set; }
      abstract public bool ConsumesFuel { get; set; }
      abstract public bool Living  { get; set; }

// The example displays the following output: 
//    Virtual properties in type Transportation.MeansOfTransportation: 
//       HasWheels (type System.Boolean) 
//       Wheels (type System.Int32) 
//       ConsumesFuel (type System.Boolean) 
//       Living (type System.Boolean)

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
© 2015 Microsoft