DynamicMethod.ReturnTypeCustomAttributes Property
.NET Framework 4
Gets the custom attributes of the return type for the dynamic method.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.Reflection.ICustomAttributeProviderAn ICustomAttributeProvider representing the custom attributes of the return type for the dynamic method.
Implements
_MethodInfo.ReturnTypeCustomAttributesCustom attributes are not supported on the return type of a dynamic method, so the array of custom attributes returned by the GetCustomAttributes method is always empty.
The following code example shows how to display the custom attributes of the return type of a dynamic method. This code example is part of a larger example provided for the DynamicMethod class.
// ReturnTypeCustomAttributes returns an ICustomeAttributeProvider // that can be used to enumerate the custom attributes of the // return value. At present, there is no way to set such custom // attributes, so the list is empty. if (hello.ReturnType == typeof(void)) { Console.WriteLine("The method has no return type."); } else { ICustomAttributeProvider caProvider = hello.ReturnTypeCustomAttributes; object[] returnAttributes = caProvider.GetCustomAttributes(true); if (returnAttributes.Length == 0) { Console.WriteLine("\r\nThe return type has no custom attributes."); } else { Console.WriteLine("\r\nThe return type has the following custom attributes:"); foreach( object attr in returnAttributes ) { Console.WriteLine("\t{0}", attr.ToString()); } } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.