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.IsPublic

Retrieves whether this is a public method.

[Visual Basic]
Public ReadOnly Property IsPublic As Boolean
[C#]
public bool IsPublic {get;}
[C++]
public: __property bool get_IsPublic();
[JScript]
public function get IsPublic() : Boolean;

Property Value

Read-only.

true if this method is public; otherwise, false.

Remarks

To get the MethodBase, first get the type. From the type, get the method. From the method, get the Methodbase. If the method base is other than a public method, it is protected and cannot be readily accessed. To access a non public method, in the GetMethod method, set the BindingFlags to NonPublic.

Example [C#]

[C#]

class
methodbase
{
   public static int Main(string[] args)
   {     

      Console.WriteLine("\nReflection.MethodBase");
      
      //Get the MethodBase of a method.
 
      //Get the type
      Type MyType = Type.GetType("System.MulticastDelegate");
 
      //Get and display the method
      MethodBase Mymethodbase = MyType.GetMethod("RemoveImpl",BindingFlags.NonPublic);
 
      Console.Write("\nMymethodbase = " + Mymethodbase);
 
      bool Myispublic = Mymethodbase.IsPublic;
      if (Myispublic)
         Console.Write ("\nMymethodbase is a public method");
      else
         Console.Write ("\nMymethodbase is not a public method");
      
      return 0;
   }
}
Produces the following output

Reflection.MethodBase
Mymethodbase = System.Delegate RemoveImpl (System.Delegate)
Mymethodbase is not a public method

See Also

MethodBase Class | MethodBase Members | System.Reflection Namespace | Boolean | BindingFlags