# InMemoryVariableStorage

Class in [Yarn.Unity](/2.3/api/csharp/yarn.unity.md)

Inherits from [`VariableStorageBehaviour`](/2.3/api/csharp/yarn.unity/yarn.unity.variablestoragebehaviour.md)

## Summary

A simple implementation of VariableStorageBehaviour.

```csharp
public class InMemoryVariableStorage : VariableStorageBehaviour, IEnumerable<KeyValuePair<string, object>>
```

## Remarks

This class stores variables in memory, and is erased when the game exits.

This class also has basic serialization and save/load example functions.

You can also enumerate over the variables by using a `foreach` loop:

```
// 'storage' is an InMemoryVariableStorage
foreach (var variable in storage) {
string name = variable.Key;
System.Object value = variable.Value;
}
```

Note that as of v2.0, this class no longer uses Yarn.Value, to enforce static typing of declared variables within the Yarn Program.

## Fields

| Name                                                                                                                       | Description |
| -------------------------------------------------------------------------------------------------------------------------- | ----------- |
| [showDebug](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.showdebug.md) |             |

## Methods

| Name                                                                                                                                                                                                                          | Description                                                                                    |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [Clear()](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.clear.md)                                                                                                          | Removes all variables from storage.                                                            |
| [Contains(string)](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.contains.md)                                                                                              | returns a boolean value representing if the particular variable is inside the variable storage |
| [GetAllVariables()](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.getallvariables.md)                                                                                      |                                                                                                |
| [GetDebugList()](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.getdebuglist.md)                                                                                            |                                                                                                |
| [SetAllVariables(Dictionary\<string, float>,Dictionary\<string, string>,Dictionary\<string, bool>,bool)](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.setallvariables.md) |                                                                                                |
| [SetValue(string,bool)](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.setvalue-3.md)                                                                                       |                                                                                                |
| [SetValue(string,float)](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.setvalue-2.md)                                                                                      |                                                                                                |
| [SetValue(string,string)](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.setvalue-1.md)                                                                                     |                                                                                                |
| [TryGetValue(string,T)](/2.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage/yarn.unity.inmemoryvariablestorage.trygetvalue.md)                                                                                      | Retrieves a `Yarn.Value` by name.                                                              |


---

# 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.3/api/csharp/yarn.unity/yarn.unity.inmemoryvariablestorage.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.
