MethodImplAttributes 枚举

定义

指定方法实现的属性的标志。

此枚举支持其成员值的按位组合。

此 API 支持产品基础结构,不能在代码中直接使用。

public enum class MethodImplAttributes
public enum MethodImplAttributes
[System.Flags]
[System.Serializable]
public enum MethodImplAttributes
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum MethodImplAttributes
type MethodImplAttributes = 
[<System.Flags>]
[<System.Serializable>]
type MethodImplAttributes = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type MethodImplAttributes = 
Public Enum MethodImplAttributes
继承
MethodImplAttributes
属性

字段

AggressiveInlining 256

指定方法应尽可能内联。

AggressiveOptimization 512

指定应尽可能优化的方法。

CodeTypeMask 3

指定有关代码类型的标志。

ForwardRef 16

指定方法是未定义的。

IL 0

指定方法实现位于 Microsoft 中间语言 (MSIL) 中。

InternalCall 4096

指定内部调用。

Managed 0

指定方法在托管代码中实现。

ManagedMask 4

指定方法是在托管代码还是非托管代码中实现。

MaxMethodImplVal 65535

指定范围检查值。

Native 1

指定方法实现为本机。

NoInlining 8

指定方法不能内联。

NoOptimization 64

指定在调试可能的代码生成问题时,方法不由实时 (JIT) 编译器或本机代码生成优化(请参阅 Ngen.exe)。

OPTIL 2

指定方法实现位于优化中间语言 (OPTIL) 中。

PreserveSig 128

指定方法签名是完全按照声明导出的。

Runtime 3

指定方法实现由运行时提供。

SecurityMitigations 1024

此成员留待将来使用。 它是在 .NET Framework 4.8 中引入的。

Synchronized 32

指定方法是通过正文的单线程方法。 静态方法(在 Visual Basic 中为Shared )在类型上锁定,而实例方法在实例上锁定。 为此,也可以使用 C# lock 语句 或 Visual Basic SyncLock 语句

Unmanaged 4

指定方法在非托管代码中实现。

注解

使用按位 OR 操作组合属性,如下所示:

代码实现掩码:

  • CodeTypeMask

  • IL

  • Native

  • OPTIL

  • Runtime

托管掩码:

  • ManagedMask

  • Unmanaged

  • Managed

实现信息和互操作掩码:

  • ForwardRef

  • PreserveSig

  • InternalCall

  • Synchronized

  • NoInlining

  • NoOptimization

  • MaxMethodImplVal

  • SecurityMitigations (从 .NET Framework 4.8.) 开始可用

备注

对于公共类型,不建议对实例或类型进行锁定(与 标志一 Synchronized 样),因为自己的代码以外的代码可能会对公共类型和实例进行锁定。 这可能会导致死锁或其他同步问题。

适用于

另请参阅