> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.unity/ks.unity.ksserializabledictionary-2.md).

# Class ksSerializableDictionary\<Key, Value>

Namespace: [KS.Unity](/reactor/api-reference/ks.unity.md)\
Assembly: KSUnity.dll

A dictionary that implements ISerializationCallbackReceiver for serializing key value data.

```csharp
[Serializable]
public class ksSerializableDictionary<Key, Value> : IDictionary<Key, Value>, ICollection<KeyValuePair<Key, Value>>, IEnumerable<KeyValuePair<Key, Value>>, ksISerializableDictionary, IDictionary, ICollection, IEnumerable, ISerializationCallbackReceiver
```

#### Type Parameters

`Key`

`Value`

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksSerializableDictionary\<Key, Value>](/reactor/api-reference/ks.unity/ks.unity.ksserializabledictionary-2.md)

#### Implements

[IDictionary\<Key, Value>](https://learn.microsoft.com/dotnet/api/system.collections.generic.idictionary-2), [ICollection\<KeyValuePair\<Key, Value>>](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1), [IEnumerable\<KeyValuePair\<Key, Value>>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [ksISerializableDictionary](/reactor/api-reference/ks.unity/ks.unity.ksiserializabledictionary.md), [IDictionary](https://learn.microsoft.com/dotnet/api/system.collections.idictionary), [ICollection](https://learn.microsoft.com/dotnet/api/system.collections.icollection), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable), ISerializationCallbackReceiver

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksSerializableDictionary() <a href="#ks_unity_ksserializabledictionary_2__ctor" id="ks_unity_ksserializabledictionary_2__ctor"></a>

Constructor

```csharp
public ksSerializableDictionary()
```

### ksSerializableDictionary(ICollection\<KeyValuePair\<Key, Value>>) <a href="#ks_unity_ksserializabledictionary_2__ctor_system_collections_generic_icollection_system_collections" id="ks_unity_ksserializabledictionary_2__ctor_system_collections_generic_icollection_system_collections"></a>

Constructor

```csharp
public ksSerializableDictionary(ICollection<KeyValuePair<Key, Value>> keyValues)
```

#### Parameters

`keyValues` [ICollection](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1)<[KeyValuePair](https://learn.microsoft.com/dotnet/api/system.collections.generic.keyvaluepair-2)\<Key, Value>>

Key value pairs to populate the dictionary with.

## Properties

### Count <a href="#ks_unity_ksserializabledictionary_2_count" id="ks_unity_ksserializabledictionary_2_count"></a>

The number of key/value pairs in the dictionary.

```csharp
public int Count { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### IsReadOnly <a href="#ks_unity_ksserializabledictionary_2_isreadonly" id="ks_unity_ksserializabledictionary_2_isreadonly"></a>

Is the dictionary read-only?

```csharp
public bool IsReadOnly { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### Keys <a href="#ks_unity_ksserializabledictionary_2_keys" id="ks_unity_ksserializabledictionary_2_keys"></a>

Key collection.

```csharp
public ICollection<Key> Keys { get; }
```

#### Property Value

[ICollection](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1)\<Key>

### Values <a href="#ks_unity_ksserializabledictionary_2_values" id="ks_unity_ksserializabledictionary_2_values"></a>

Value collection.

```csharp
public ICollection<Value> Values { get; }
```

#### Property Value

[ICollection](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1)\<Value>

### this\[Key] <a href="#ks_unity_ksserializabledictionary_2_item__0" id="ks_unity_ksserializabledictionary_2_item__0"></a>

Gets or sets the value associated with a key.

```csharp
public Value this[Key key] { get; set; }
```

#### Property Value

Value

## Methods

### Add(Key, Value) <a href="#ks_unity_ksserializabledictionary_2_add__0__1" id="ks_unity_ksserializabledictionary_2_add__0__1"></a>

Adds a key/value pair to the dictionary. Throws an exception if the key is already in the dictionary. See Add.

```csharp
public void Add(Key key, Value value)
```

#### Parameters

`key` Key

Key to add.

`value` Value

Value to add.

### Clear() <a href="#ks_unity_ksserializabledictionary_2_clear" id="ks_unity_ksserializabledictionary_2_clear"></a>

Clears the dictionary. See Clear.

```csharp
public void Clear()
```

### ContainsKey(Key) <a href="#ks_unity_ksserializabledictionary_2_containskey__0" id="ks_unity_ksserializabledictionary_2_containskey__0"></a>

Checks if a key is in the dictionary. See ContainsKey.

```csharp
public bool ContainsKey(Key key)
```

#### Parameters

`key` Key

Key to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the key is in the dictionary.

### ContainsValue(Value) <a href="#ks_unity_ksserializabledictionary_2_containsvalue__1" id="ks_unity_ksserializabledictionary_2_containsvalue__1"></a>

Checks if a value is in the dictionary. See ContainsValue.

```csharp
public bool ContainsValue(Value value)
```

#### Parameters

`value` Value

Value to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the value is in the dictionary.

### GetEnumerator() <a href="#ks_unity_ksserializabledictionary_2_getenumerator" id="ks_unity_ksserializabledictionary_2_getenumerator"></a>

Enumerates the key/value pairs in the dictionary.

```csharp
public IEnumerator<KeyValuePair<Key, Value>> GetEnumerator()
```

#### Returns

[IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1)<[KeyValuePair](https://learn.microsoft.com/dotnet/api/system.collections.generic.keyvaluepair-2)\<Key, Value>>

Enumerator

### Remove(Key) <a href="#ks_unity_ksserializabledictionary_2_remove__0" id="ks_unity_ksserializabledictionary_2_remove__0"></a>

Removes a key from the dictionary. See Remove.

```csharp
public bool Remove(Key key)
```

#### Parameters

`key` Key

Key to remove.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the key was removed from the dictionary. False if the key was not in the dictionary.

### TryGetValue(Key, out Value) <a href="#ks_unity_ksserializabledictionary_2_trygetvalue__0__1" id="ks_unity_ksserializabledictionary_2_trygetvalue__0__1"></a>

Tries to get the value for a key from the dictionary. See TryGetValue.

```csharp
public bool TryGetValue(Key key, out Value value)
```

#### Parameters

`key` Key

Key to get value for.

`value` Value

The value for the key.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the key was in the dictionary.
