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>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IKeyedObservableCollection<T>, IObservableCollection<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable where T : class, IKeyedObject
Type Parameters:
T -
Inheritance:
System.Object System.Collections.ObjectModel.Collection<T> SimpleObservableCollection<T> KeyedObservableCollection<T> Object
Implements:
IKeyedObservableCollection<T> IObservableCollection<T>

Constructors

KeyedSynchronizedCollection()

public KeyedSynchronizedCollection()

Properties

Item[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 System.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 System.String

The key to locate in the collection.

Returns

System.Int32:

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

InsertItem(Int32, T)

Inserts an item into the collection at the specified index.

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

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 System.String

The key to locate in the collection.

Returns

System.Boolean:

true if a T was removed; otherwise, false.

RemoveItem(Int32)

Removes the item at the specified index.

protected override void RemoveItem(int index)
Parameter Type Description
index System.Int32

The index of the item to remove.

SetItem(Int32, T)

Replaces the item at the specified index.

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

The index of the item to replace.

item T

The item with which to replace.

Inherited Members

Extension Methods