NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MethodAttributes Enumeration

Comprises flags that specify the attributes of a method. These flags are defined in corhdr.h.

[Visual Basic]
Public Enum MethodAttributes
[C#]
public enum MethodAttributes
[C++]
public enum MethodAttributes

[JScript] In JScript, you can use the enumerations in the NGWS frameworks, but you cannot define your own.

Remarks

The MethodAttributes enumeration defines the attributes that can be associated with a method. This set of attributes is a combination of Enumeration and bit flags.

The enumerated value is a number representing the bitwise OR of the attributes implemented on the method. The attributes are logically bitwise OR'd in the following groups:

Member access masks. Use these masks to retrieve accessibility information:

Method contract attributes:

Vtable layout masks. Use these masks to retrieve vtable attributes.

Method implementation attributes:

Interop attributes:

Reserved flags for runtime use only:

Members

Member Name Description
Abstract Indicates that the class does not provide an implementation of this method.
Assembly Indicates that the method is accessible to any class of this assembly.
FamANDAssem Indicates that the method is accessible only to members of this class and its subclasses.
Family Indicates that the method is accessible only to members of this class and its subclasses.
FamORAssem Indicates that the method is accesssible to subclasses anywhere, as well as to any class in the assembly.
Final Indicates that the method cannot be overriden.
HasSecurity Indicates that the method has security associated with it. Reserved flag for runtime use only.
HideBySig Indicates that the method hides by name and signature; otherwise, by name only.
MemberAccessMask Retrieves accessibility information.
NewSlot Indicates that the method always gets a new slot in the vtable.
PinvokeImpl Indicates that the method implementation is forwarded through PInvoke (Platform Invocation Services).
Private Indicates that the method is accessible only to the current class and the parent class.
PrivateScope Indicates that the member cannot be referenced.
Public Indicates that the method is accessible to any object for which this object is in scope.
RequireSecObject Indicates that the method calls another method containing security code. Reserved flag for runtime use only.
ReservedMask Indicates a reserved flag for runtime use only.
ReuseSlot Indicates that the method will reuse an existing slot in the vtable. This is the default behavior.
RTSpecialName Indicates that the NGWS runtime checks the name encoding.
SpecialName Indicates that the method is special. The name describes how this method is special.
Static Indicates that the method is defined on the type; otherwise, it is defined per instance.
UnmanagedExport Indicates that the managed method is exported by thunk to unmanaged code.
Virtual Indicates that the method is virtual.
VtableLayoutMask Retrieves vtable attributes.

Requirements

Namespace: System.Reflection

Assembly: mscorlib.dll

Example [C#]

[C#]

class methodattributesenum
{
   public void Mymethod (
      [in] int int1m, out
string str2m, ref string str3m)
   {
      str2m = "in
Mymethod";
   }
 
   public static int
Main(string[] args)
   {
      Console.WriteLine ("\nReflection.Parameterinfo");
      
      //Get the
MethodAttributes Enumeration of a method.
 
      //Get the type
      Type MyType =
Type.GetType("methodattributesenum");
 
      //Get and display
the method
      MethodBase
Mymethodbase = MyType.GetMethod("Mymethod");
 
     
Console.Write("\nMymethodbase = " + Mymethodbase);
 
      //Get the
MethodAttribute enumerated value
      MethodAttributes
Myattributes = Mymethodbase.Attributes;
 
      //Display the
attributes for the method
      Console.Write
("\nMyattributes = " + (int) Myattributes);
      //allow the next
write only if the attribute
      // is exactly a
defined attribute.
      if
(EnumInfo.IsDefined(Type.GetType(
        
"System.Reflection.MethodAttributes"),
        
(int)Myattributes))
         {
Console.Write
("\nToString = " + EnumInfo.ToString(
  
Type.GetType("System.Reflection.MethodAttributes"),
  
(int)Myattributes));
         }
      return 0;
   }
}
Produces the following output
Reflection.Parameterinfo
 
Mymethodbase = Void Mymethod (Int32, System.String ByRef,
System.String ByRef)
Myattributes = 6
ToString = Public

See Also

System.Reflection Namespace