DynamicMethod.DeclaringType Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the type that declares the method, which is always nullNothingnullptra null reference (Nothing in Visual Basic) for dynamic methods.

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

Syntax

Public Overrides ReadOnly Property DeclaringType As Type
public override Type DeclaringType { get; }

Property Value

Type: System..::.Type
Always nullNothingnullptra null reference (Nothing in Visual Basic).

Remarks

This property always returns nullNothingnullptra null reference (Nothing in Visual Basic) for dynamic methods. Even when a dynamic method is logically associated with a type, it is not declared by the type.

Examples

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 Nothing for dynamic
' methods.
If hello.DeclaringType Is Nothing Then
   outputBlock.Text &= "DeclaringType is always Nothing for dynamic methods." & vbLf
Else
   outputBlock.Text += String.Format("DeclaringType: {0}", hello.DeclaringType) & vbLf
End If
// 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";
}

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Platforms

Windows Phone

See Also

Reference

DynamicMethod Class

System.Reflection.Emit Namespace