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!

MethodBase.Attributes

Retrieves the attributes for this method.

[Visual Basic]
MustOverride Public ReadOnly Property Attributes As _
   MethodAttributes
[C#]
public MethodAttributes Attributes {abstract get;}
[C++]
public: __property virtual MethodAttributes get_Attributes() = 0;
[JScript]
public abstract function get Attributes() : MethodAttributes;

Property Value

Read-only.

Remarks

All members have a set of attributes, which are defined in relation to the specific type of member.

To get the MethodAttributes, first get the type. From the type, get the method. From the method, get the MethodAttributes.

The Attributes is a MethodAttributes enumeration defining the attributes that may be associated with this method. This enumerated value can be used to determine the Public/ Private attributes of the method.

Example [C#]

[C#]

class methodbase
{
   public void Mymethod ( [in] int int1m, out string str2m, ref string str3m)
   {
      str2m = "in Mymethod";
   }

   public static int Main(string[] args)
   {      
      Console.WriteLine ("\nReflection.MethodBase");
      
      //Get the MethodBase of a method.
      Type MyType = Type.GetType("methodbase");

      //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.MethodBase

Mymethodbase = Void Mymethod (Int32, System.String ByRef, System.String ByRef)
Myattributes = 6
ToString = Public

See Also

MethodBase Class | MethodBase Members | System.Reflection Namespace