# RegisterFunction(string,Func\<T1, TResult>)

Method in [Library](/2.1/api/csharp/yarn/yarn.library.md)

## Summary

Registers a new function that returns a value, which can be called from a Yarn program.

```csharp
public void RegisterFunction<T1, TResult>(string name, Func<T1, TResult> implementation)
```

## Parameters

| Name                                      | Description                                           |
| ----------------------------------------- | ----------------------------------------------------- |
| `string` name                             | The name of the function.                             |
| `System.Func<T1, TResult>` implementation | The method to be invoked when the function is called. |

## Type Parameters

| Name    | Description                                |
| ------- | ------------------------------------------ |
| TResult | The return type of the function.           |
| TResult | The return type of the function.           |
| T1      | The type of the function's first argument. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yarnspinner.dev/2.1/api/csharp/yarn/yarn.library/yarn.library.registerfunction-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
