# TryGetInitialValue\<T>(string,T)

Method in [Program](/3.1/api/csharp/yarn/yarn.program.md)

## Summary

Attempts to fetch a value for a variable named `variableName` from this program's collection of initial values.

```csharp
public bool TryGetInitialValue<T>(string variableName, out T result)
```

## Parameters

| Name                  | Description                                                                                                                                   |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `string` variableName | The name of the variable to retrieve a value for.                                                                                             |
| `T` result            | On return, contains the value of the variable, or the default value of `T` if not known. Depending on what `T` is, this value may be `null` . |

## Type Parameters

| Name | Description                       |
| ---- | --------------------------------- |
| T    | The type of variable to retrieve. |

## Returns

`true` if an initial value for `variableName` was found; `false` otherwise.


---

# 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/3.1/api/csharp/yarn/yarn.program/yarn.program.trygetinitialvalue.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.
