# SerializedDictionary

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

Inherits from `IDictionary`2\`

## Summary

An `IDictionary<TKey,TValue>` that can be serialized as part of a Unity object.

```csharp
public class SerializedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ISerializationCallbackReceiver
```

## Remarks

Prior to Unity 2020, dictionaries cannot be directly serialized by Unity. This class is a workaround; it provides an API identical to `Dictionary<TKey, TValue>` , and stores its contents as two `List<T>` s: one for `TKey` , and one for `TValue` .

## Type Parameters

| Name   | Description                               |
| ------ | ----------------------------------------- |
| TKey   | The type of key used in the dictionary.   |
| TValue | The type of value used in the dictionary. |

## Indexers

| Name                                                                                                                   | Description |
| ---------------------------------------------------------------------------------------------------------------------- | ----------- |
| [this\[TKey key\]](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.this.md) |             |

## Methods

| Name                                                                                                                                                | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| [Add(TKey,TValue)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.add-1.md)                             |             |
| [Add(KeyValuePair\<TKey, TValue>)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.add-2.md)             |             |
| [Clear()](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.clear.md)                                      |             |
| [Contains(KeyValuePair\<TKey, TValue>)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.contains.md)     |             |
| [ContainsKey(TKey)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.containskey.md)                      |             |
| [CopyTo(KeyValuePair\<TKey, TValue>\[\],int)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.copyto.md) |             |
| [GetEnumerator()](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.getenumerator.md)                      |             |
| [Remove(TKey)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.remove-1.md)                              |             |
| [Remove(KeyValuePair\<TKey, TValue>)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.remove-2.md)       |             |
| [TryGetValue(TKey,TValue)](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.trygetvalue.md)               |             |

## Properties

| Name                                                                                                                   | Description |
| ---------------------------------------------------------------------------------------------------------------------- | ----------- |
| [Count](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.count.md)           |             |
| [IsReadOnly](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.isreadonly.md) |             |
| [Keys](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.keys.md)             |             |
| [Values](/2.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary/yarn.unity.serializeddictionary.values.md)         |             |


---

# 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.0/api/csharp/yarn.unity/yarn.unity.serializeddictionary.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.
