[Yandex Cloud documentation](../../../../index.md) > [Yandex Cloud Functions](../../../index.md) > [Developing in .NET Core](../index.md) > [Programming model](index.md) > YcFunction interface

# Using the YcFunction interface to set a handler in C#

You can set a handler in C# by implementing the [YcFunction](https://github.com/yandex-cloud/dotnet-sdk/blob/master/Yandex.Cloud.SDK/Functions/YcFunction.cs) interface. To do this, add an [SDK](../sdk.md) to the [dependencies](../dependencies.md).

{% note warning %}

You must specify both values for the `YcFunction` type parameters: the first one being the input argument type and the second one, the return value type. The `handle` method also has [invocation context](../context.md) as its second argument.

{% endnote %}

Example of a valid handler:
```C#
public class Handler : YcFunction<int, String> {
  public String FunctionHandler(int i, Context c) {
    return String.valueOf(i);
  }
}
```

Examples of invalid handlers:
```C#
// YcFunction has only one parameter type specified
// Handler should not have any type parameters.
public class Handler<T> : YcFunction<T, int> {
  public int FunctionHandler(T i, Context c) {
    return 2;
  }
}
```

```C#
// YcFunction has neither of the parameter types specified
public class Handler : YcFunction {
  public Object FunctionHandler(Object i, Context c) {
    return i;
  }
}
```

Learn more about the handler requirements [here](index.md).

You can use any classes as input and return types.

{% note info %}

Fields of these classes can have any [access modifiers](https://docs.microsoft.com/ru-ru/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers). If a field is non-public, it requires the `getter` public method. Otherwise, the field will not be included in the response.

{% endnote %}

## Example {#example}

### Function information output {#http-info}

The following function:
1. Receives a number as an input.
1. Outputs the function data obtained from the invocation context to the execution log.
1. Returns data on whether the received number is even.

{% note warning %}

To invoke the function, use the [Yandex Cloud CLI](../../../concepts/function-invoke.md) or an HTTP request with the `?integration=raw` parameter.

{% endnote %}

`Handler.cs`:

```C#
using Yandex.Cloud.Functions;

public class Handler : YcFunction<int, bool> {

  public bool FunctionHandler(int number, Context c) {
    Console.WriteLine($"Function name: {c.FunctionId}");
    Console.WriteLine($"Function version: {c.FunctionVersion}");
    Console.WriteLine($"Service account token: {c.TokenJson}");
    return number % 2 == 0;
  }
}
```

Example of input data:

```text
41
```

The log will contain the following:

```text
Function name: <function_name>
Function version: <function_version_ID>
Service account token: <service_account_token>
```

Returned string:

```text
false
```