Class

# MethodInfo

<div class="rst-class">

forsearch

</div>

Introspection

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Provides information on the methods of the class instance via the `Introspection</api/language/introspection/introspection>` system.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                  | Type                                             | Read-Only | Shared |
|---------------------------------------|--------------------------------------------------|-----------|--------|
| `IsPrivate<methodinfo.isprivate>`     | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsProtected<methodinfo.isprotected>` | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsPublic<methodinfo.ispublic>`       | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsShared<methodinfo.isshared>`       | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `Name<methodinfo.name>`               | `String</api/data_types/string>`                 | ✓         |        |
| `ReturnType<methodinfo.returntype>`   | `TypeInfo</api/language/introspection/typeinfo>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                      | Parameters                                                                                                                                   | Returns                                                      | Shared |
|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|--------|
| `GetAttributes<methodinfo.getattributes>` |                                                                                                                                              | `AttributeInfo()</api/language/introspection/attributeinfo>` |        |
| `GetParameters<methodinfo.getparameters>` |                                                                                                                                              | `ParameterInfo()</api/language/introspection/parameterinfo>` |        |
| `Invoke<methodinfo.invoke>`               | base As `Object</api/data_types/additional_types/object>`, `Optional</api/language/optional>` params() As `Variant</api/data_types/variant>` |                                                              |        |
|                                           | base As `Object</api/data_types/additional_types/object>`, `Optional</api/language/optional>` params() As `Variant</api/data_types/variant>` | `Variant</api/data_types/variant>`                           |        |

## Property descriptions

<div id="methodinfo.isprivate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.IsPrivate

**IsPrivate** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the item has Private scope.
>
> This property is read-only.
>
> The following example checks the IsPrivate property before taking an action.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   If prop.IsPrivate Then
>     ' take an action here..
>   End If
> Next
> ```

<div id="methodinfo.isprotected">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.IsProtected

**IsProtected** As `Boolean</api/data_types/boolean>`

> Is `True</api/language/true>`, the item has Protected scope.
>
> This property is read-only.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   If prop.IsProtected Then
>     ' take an action here..
>   End If
> Next
> ```

<div id="methodinfo.ispublic">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.IsPublic

**IsPublic** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the item has Public scope.
>
> This property is read-only.
>
> This example checks the IsPublic property before taking an action.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   If prop.IsPublic Then
>     ' take an action here..
>   End If
> Next
> ```

<div id="methodinfo.isshared">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.IsShared

**IsShared** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, it is a shared method and does not require a `Self</api/language/self_keyword>` parameter when called by `Introspection</api/language/introspection/introspection>`.
>
> This property is read-only.

<div id="methodinfo.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.Name

**Name** As `String</api/data_types/string>`

> The name of the item. This is only the class name. To get the full namespace path, use FullName instead.
>
> This property is read-only.
>
> This code gets the list of properties for the passed type instance.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   ListBox1.AddRow(prop.Name)
> Next
> ```

<div id="methodinfo.returntype">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.ReturnType

**ReturnType** As `TypeInfo</api/language/introspection/typeinfo>`

> If the method returns a value, this is the datatype of the returned value. If the method does not return a value, ReturnType is `Nil</api/language/nil>`.
>
> This property is read-only.

## Method descriptions

<div id="methodinfo.getattributes">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.GetAttributes

**GetAttributes** As `AttributeInfo()</api/language/introspection/attributeinfo>`

> Returns an array of `AttributeInfo</api/language/introspection/attributeinfo>` objects.
>
> The following gets the attributes of window1.
>
> ``` xojo
> Var myAttributes() As Introspection.AttributeInfo = Introspection.GetType(Window1).GetAttributes
> ```

<div id="methodinfo.getparameters">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.GetParameters

**GetParameters** As `ParameterInfo()</api/language/introspection/parameterinfo>`

> Returns an array of `ParameterInfo</api/language/introspection/parameterinfo>` items. Use GetParameters to obtain datatype information on the method's parameters.

<div id="methodinfo.invoke">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MethodInfo.Invoke

**Invoke**(base As `Object</api/data_types/additional_types/object>`, `Optional</api/language/optional>` params() As `Variant</api/data_types/variant>`)

> Invokes the method, given its info object and an instance of the class that created it. You can use `Nil</api/language/nil>` as the base object if calling a shared method. Pass an array of variants for the method's parameter values. You will get an `OutOfBoundsException</api/exceptions/outofboundsexception>` if the number of parameters does not match or an `IllegalCastException</api/exceptions/illegalcastexception>` if the types do not match.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

MethodInfo.Invoke

**Invoke**(base As `Object</api/data_types/additional_types/object>`, `Optional</api/language/optional>` params() As `Variant</api/data_types/variant>`) As `Variant</api/data_types/variant>`

> Invokes the method, given its info object and an instance of the class that created it. You can use `Nil</api/language/nil>` as the base object if calling a shared method. Pass an array of variants for the method's parameter values. You will get an `OutOfBoundsException</api/exceptions/outofboundsexception>` if the number of parameters does not match or an `IllegalCastException</api/exceptions/illegalcastexception>` if the types do not match.

## Sample code

The following gets the methods of the DateTime class instance:

``` xojo
Var d As DateTime = DateTime.Now
Var myDbMethods() As Introspection.MethodInfo = _
  Introspection.GetType(d).GetMethods

For Each method As Introspection.MethodInfo In MyDbMethods
  Listbox1.AddRow(method.Name)
Next
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`MemberInfo</api/language/introspection/memberinfo>` parent class; `Introspection</api/language/introspection/introspection>` module; `AttributeInfo</api/language/introspection/attributeinfo>`, `ConstructorInfo</api/language/introspection/constructorinfo>`, `MemberInfo</api/language/introspection/memberinfo>`, `ObjectIterator</api/language/introspection/objectiterator>`, `ParameterInfo</api/language/introspection/parameterinfo>`, `PropertyInfo</api/language/introspection/propertyinfo>`, `TypeInfo</api/language/introspection/typeinfo>` classes; `GetTypeInfo</api/language/introspection/gettypeinfo>` function.

</div>
