C# Type TypeInitializer
Description
Type TypeInitializer
gets the initializer for the Type.
Syntax
Type.TypeInitializer
has the following syntax.
[ComVisibleAttribute(true)]
public ConstructorInfo TypeInitializer { get; }
Example
using System;// w w w . j a va2s .c o m
using System.Reflection;
class MyClass
{
public int myField = 10;
}
class Type_TypeHandle
{
public static void Main()
{
try
{
MyClass myClass = new MyClass();
Type myClassType = myClass.GetType();
Console.WriteLine(myClassType.TypeInitializer);
}
catch(Exception e)
{
Console.WriteLine("Exception: {0}", e.Message );
}
}
}
The code above generates the following result.