C# Type GetType(String)
Description
Type GetType(String)
gets the Type with the specified
name, performing a case-sensitive search.
Syntax
Type.GetType(String)
has the following syntax.
public static Type GetType(
string typeName
)
Parameters
Type.GetType(String)
has the following parameters.
typeName
- The assembly-qualified name of the type to get. See AssemblyQualifiedName. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.
Returns
Type.GetType(String)
method returns The type with the specified name, if found; otherwise, null.
Example
The following example retrieves the type of System.Int32 and uses that type object to display the FullName property of System.Int32.
using System;/* w w w . j a va 2 s. c om*/
namespace MyTypeNameSpace
{
class MyClass
{
public static void Main(string[] arg)
{
Type myType1 = Type.GetType("System.Int32");
Console.WriteLine("The full name is {0}.", myType1.FullName);
Type myType2 = Type.GetType("NoneSuch", true);
Console.WriteLine("The full name is {0}.", myType2.FullName);
}
}
}
The code above generates the following result.