```html System.Reflection.MethodBase Class (System.Reflection) | .NET API Browser
.NET API Browser Docs Home

MethodBase Class

Represents methods (including constructors) in the reflection system.

Syntax

public abstract class MethodBase : MemberInfo

Inheritance

System.Object
   ↳ System.Reflection.MemberInfo
        ↳ System.Reflection.MethodBase

Summary

The MethodBase class provides information about methods and constructors (including access level, parameters, generic arguments, and custom attributes). It also enables the dynamic invocation of a method or constructor.

Properties

NameTypeDescription
IsAbstractboolGets a value indicating whether the method is abstract.
IsConstructorboolGets a value indicating whether the method is a constructor.
IsFamilyboolGets a value indicating whether the method is protected.
IsPublicboolGets a value indicating whether the method is public.
IsStaticboolGets a value indicating whether the method is static.

Methods

NameReturn TypeSignature
Invoke object public object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
GetParameters ParameterInfo[] public ParameterInfo[] GetParameters()
GetCustomAttributes object[] public override object[] GetCustomAttributes(bool inherit)

Example

Use MethodBase to call a private method dynamically:

using System;
using System.Reflection;

class Demo
{
    private void Secret(string msg)
    {
        Console.WriteLine($"Secret: {msg}");
    }

    static void Main()
    {
        var d = new Demo();
        MethodInfo mi = typeof(Demo).GetMethod("Secret", BindingFlags.Instance | BindingFlags.NonPublic);
        mi.Invoke(d, new object[] { "Hello from reflection!" });
    }
}


See also

```