Interface IObjectDictionary
Describes dictionaries mapping case-sensitive strings to objects along with nice generic methods that converts item values to specific types.
Namespace: Neon.Collections
Assembly: Neon.Common.dll
Syntax
public interface IObjectDictionary
Methods
Get<TValue>(string)
Returns the value of an item converted to a specific type.
Declaration
TValue Get<TValue>(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key. |
Returns
| Type | Description |
|---|---|
| TValue | The value converted to |
Type Parameters
| Name | Description |
|---|---|
| TValue | The result type. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if key is |
| KeyNotFoundException | Thrown by the getter if the key doesn't exist. |
| InvalidCastException | Thrown if the item value cannot be cast into a |
Get<TValue>(string, TValue)
Returns the value of an item converted to a specific type.
Declaration
TValue Get<TValue>(string key, TValue @default = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key. |
| TValue | default | Secifies the default value to return if the key doesn't exist. |
Returns
| Type | Description |
|---|---|
| TValue | The value converted to |
Type Parameters
| Name | Description |
|---|---|
| TValue | The result type. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if key is |
| InvalidCastException | Thrown if the item value cannot be cast into a |
TryGetValue<TValue>(string, out TValue)
Attempts to retrieve a specific value from the dictionary.
Declaration
bool TryGetValue<TValue>(string key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key. |
| TValue | value | Returns as the value when the key exists. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| TValue | The result type. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if key is |