Share via


MethodImplAttribute Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Specifies the details of how a method is implemented. This class cannot be inherited.

Inheritance Hierarchy

System. . :: . .Object
  System. . :: . .Attribute
    System.Runtime.CompilerServices..::..MethodImplAttribute

Namespace:  System.Runtime.CompilerServices
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SerializableAttribute> _
<AttributeUsageAttribute(AttributeTargets.Constructor Or AttributeTargets.Method, Inherited := False)> _
Public NotInheritable Class MethodImplAttribute _
    Inherits Attribute
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets.Constructor|AttributeTargets.Method, Inherited = false)]
public sealed class MethodImplAttribute : Attribute
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets::Constructor|AttributeTargets::Method, Inherited = false)]
public ref class MethodImplAttribute sealed : public Attribute
[<Sealed>]
[<SerializableAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Constructor|AttributeTargets.Method, Inherited = false)>]
type MethodImplAttribute =  
    class
        inherit Attribute
    end
public final class MethodImplAttribute extends Attribute

The MethodImplAttribute type exposes the following members.

Constructors

  Name Description
Public method MethodImplAttribute() () () () Initializes a new instance of the MethodImplAttribute class.
Public method MethodImplAttribute(Int16) Initializes a new instance of the MethodImplAttribute class with the specified MethodImplOptions value.
Public method MethodImplAttribute(MethodImplOptions) Initializes a new instance of the MethodImplAttribute class with the specified MethodImplOptions value.

Top

Properties

  Name Description
Public property Value Gets the MethodImplOptions value describing the attributed method.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Fields

  Name Description
Public field MethodCodeType A MethodCodeType value indicating what kind of implementation is provided for this method.

Top

Remarks

You can apply this attribute to methods or constructors.

This attribute lets you customize the configuration of the method or constructor to which it applies by supplying a MethodImplOptions value to its class constructor. The members of the MethodImplOptions enumeration correspond to bit fields in the CorMethodImpl metadata table. This means that information on the attribute cannot be retrieved at run time by calling the MemberInfo.GetCustomAttributes method; instead, it is retrieved by calling either the MethodInfo.GetMethodImplementationFlags or the ConstructorInfo.GetMethodImplementationFlags method.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Runtime.CompilerServices Namespace