DynamicMethod.DeclaringType Property

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";
   outputBlock.Text += String.Format("DeclaringType: {0}", hello.DeclaringType) + "\n";


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions