In This Article

KeyedSynchronizedCollection<T> Class

Provides a thread-safe generic keyed collection that provides notifications when items are added or removed.

public class KeyedSynchronizedCollection<T> : KeyedObservableCollection<T>, IKeyedObservableCollection<T>, IObservableCollection<T> where T : class, IKeyedObject
Type Parameters:
T -
Inheritance:
object Collection<T> SimpleObservableCollection<T> KeyedObservableCollection<T> object
Implements:
IKeyedObservableCollection<T> IObservableCollection<T>

Constructors

KeyedSynchronizedCollection()

Initializes an instance of the class.

public KeyedSynchronizedCollection()

Properties

this[string]

Gets the T with the specified key.

[C#] In C#, this property is the indexer for the IKeyedObservableCollection interface.

public override T this[string key] { get; }
Parameter Type Description
key string

The key of the T to return.

Property Value

T:

The T with the specified key.

Methods

ClearItems()

Removes all items from the collection.

protected override void ClearItems()

IndexOf(string)

Searches for a T with the specified key and returns the zero-based index of the first occurrence within the entire collection.

public override int IndexOf(string key)
Parameter Type Description
key string

The key to locate in the collection.

Returns

int:

The zero-based index of the first occurrence of a T with the specified key within the entire collection, if found; otherwise, -1.

InsertItem(int, T)

Inserts an item into the collection at the specified index.

protected override void InsertItem(int index, T item)
Parameter Type Description
index int

The index at which to insert the item.

item T

The item to insert.

Remove(string)

Removes the T with the specified key.

public override bool Remove(string key)
Parameter Type Description
key string

The key to locate in the collection.

Returns

bool:

true if a T was removed; otherwise, false.

RemoveItem(int)

Removes the item at the specified index.

protected override void RemoveItem(int index)
Parameter Type Description
index int

The index of the item to remove.

SetItem(int, T)

Replaces the item at the specified index.

protected override void SetItem(int index, T item)
Parameter Type Description
index int

The index of the item to replace.

item T

The item with which to replace.

Inherited Members