This documentation is archived and is not being maintained.

MethodBase::IsPublic Property

Gets a value indicating whether this is a public method.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

virtual property bool IsPublic {
	bool get () sealed;

Property Value

Type: System::Boolean
true if this method is public; otherwise, false.

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

The following example uses the IsPublic property to display a message that indicates whether the specified method is public.

int main()
   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", static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Instance) );
   Console::Write( "\nMymethodbase = {0}", Mymethodbase );
   bool Myispublic = Mymethodbase->IsPublic;
   if ( Myispublic )
      Console::Write( "\nMymethodbase is a public method" );
      Console::Write( "\nMymethodbase is not a public method" );

   return 0;

Produces the following output

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.