# IOpcMethodCommand Members

> Reference: Defines a command used as the implementation of a method.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">IOpcMethodCommand</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
</dl>

## Methods

### CanExecute

Determines the value of the [Executable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#executable) attribute of the method ([CanExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodnode/members#canexecute)) and therefore decides whether the [Execute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcmethodcommand/members#execute) method can be called in general to execute the method implementation.

<div class="api-signature" data-lang="csharp">

```csharp
bool CanExecute(OpcContext context)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Function CanExecute(context As OpcContext) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/) | The [OpcReadAttributeValueContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadattributevaluecontext/) in case there the [Executable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#executable) attribute is read or the [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) in case there the method call is to be processed. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the method can be called; otherwise the value false.

### CanUserExecute

Determines the value of the [UserExecutable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#userexecutable) attribute of the method ([CanUserExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodnode/members#canuserexecute)) and therefore decides wether the [Execute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcmethodcommand/members#execute) method can be called by the current user to execute the method implementation.

<div class="api-signature" data-lang="csharp">

```csharp
bool CanUserExecute(OpcContext context)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Function CanUserExecute(context As OpcContext) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/) | The [OpcReadAttributeValueContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadattributevaluecontext/) in case there the [UserExecutable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#userexecutable) attribute is read or the [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) in case there the method call is to be processed. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the method can be called; otherwise the value false.

### Execute

Performs the tasks necessary to implement the logic associated with a specific method using the `context` and `inputArguments` specified.

<div class="api-signature" data-lang="csharp">

```csharp
void Execute(
    OpcMethodContext context,
    IList<object> inputArguments,
    IList<object> outputArguments)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Sub Execute(
    context As OpcMethodContext,
    inputArguments As IList(Of Object),
    outputArguments As IList(Of Object))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) | The [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) which provides the contextual information required to execute the method. |
| `inputArguments` | [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)&lt;[Object](https://learn.microsoft.com/dotnet/api/system.object)&gt; | The generic list of [object](https://learn.microsoft.com/dotnet/api/system.object) values to use / respect during the execution of the method. |
| `outputArguments` | [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)&lt;[Object](https://learn.microsoft.com/dotnet/api/system.object)&gt; | The generic list of [object](https://learn.microsoft.com/dotnet/api/system.object) values to use for out, ref (in Visual Basic ByRef) and returned values. |

**Remarks**

Any OPC UA related result information is to be set using the [Result](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/members#result) property of the `context`.

This method is (to be) only called after the call to [CanExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcmethodcommand/members#canexecute) and [CanUserExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcmethodcommand/members#canuserexecute) evaluates to the value true.
