DynamicMethod.DeclaringType Property

July 28, 2014

Gets the type that declares the method, which is always null for dynamic methods.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

public override Type DeclaringType { get; }

Property Value

Type: System.Type
Always null.

This property always returns null for dynamic methods. Even when a dynamic method is logically associated with a type, it is not declared by the type.

The following code example displays the declaring type of a dynamic method. This code example is part of a larger example provided for the DynamicMethod class.


// Display the declaring type, which is always null for dynamic
// methods.
if (hello.DeclaringType == null)
{
   outputBlock.Text += "DeclaringType is always null for dynamic methods." + "\n";
}
else
{
   outputBlock.Text += String.Format("DeclaringType: {0}", hello.DeclaringType) + "\n";
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

Show:
© 2014 Microsoft