MethodBase::IsAbstract Property
.NET Framework (current version)
Gets a value indicating whether the method is abstract.
Assembly: mscorlib (in mscorlib.dll)
An abstract member is declared on a base class and has no implementation supplied.
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 determines whether specified the method is abstract and displays the result.
using namespace System; using namespace System::Reflection; int main() { Console::WriteLine( "\nReflection.MethodBase" ); // Get the types. Type^ MyType1 = Type::GetType( "System.Runtime.Serialization.Formatter" ); Type^ MyType2 = Type::GetType( "System.Reflection.MethodBase" ); // Get and display the methods. MethodBase^ Mymethodbase1 = MyType1->GetMethod( "WriteInt32", static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Instance) ); MethodBase^ Mymethodbase2 = MyType2->GetMethod( "GetCurrentMethod", static_cast<BindingFlags>(BindingFlags::Public | BindingFlags::Static) ); Console::Write( "\nMymethodbase = {0}", Mymethodbase1 ); if ( Mymethodbase1->IsAbstract ) Console::Write( "\nMymethodbase is an abstract method." ); else Console::Write( "\nMymethodbase is not an abstract method." ); Console::Write( "\n\nMymethodbase = {0}", Mymethodbase2 ); if ( Mymethodbase2->IsAbstract ) Console::Write( "\nMymethodbase is an abstract method." ); else Console::Write( "\nMymethodbase is not an abstract method." ); return 0; }
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: