Class KeyedCollection<TKeyType, TContainedType>
Generic collection which allows lookup and adding of objects by a key
Implements
IEditableKeyedCollection<TKeyType, TContainedType>
IReadableKeyedCollection<TKeyType, TContainedType>
Namespace: Scripting
Syntax
public class KeyedCollection<TKeyType, TContainedType> : IEditableKeyedCollection<TKeyType, TContainedType>, IReadableKeyedCollection<TKeyType, TContainedType> where TContainedType : class
Type Parameters
Name | Description |
---|---|
TKeyType | The type of the key |
TContainedType | The type of the contained object |
Properties
Count
The count of items in the collection
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[TKeyType]
Get or set the object by its key
Declaration
public TContainedType this[TKeyType key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
TKeyType | key | The key |
Property Value
Type | Description |
---|---|
TContainedType | The object, or null |
Methods
Add(TKeyType, TContainedType)
Add the item with the given key
Declaration
public void Add(TKeyType key, TContainedType value)
Parameters
Type | Name | Description |
---|---|---|
TKeyType | key | They key |
TContainedType | value | The value |
Remove(TKeyType)
Remove the item specified by the key
Declaration
public void Remove(TKeyType key)
Parameters
Type | Name | Description |
---|---|---|
TKeyType | key | The key |
TryGetValue(TKeyType)
Attempt to get the value for the given key, returns null otherwise
Declaration
public TContainedType TryGetValue(TKeyType key)
Parameters
Type | Name | Description |
---|---|---|
TKeyType | key |
Returns
Type | Description |
---|---|
TContainedType |