SetItem Method
Collapse the table of content
Expand the table of content

KeyedCollection<TKey, TItem>.SetItem Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Replaces the item at the specified index with the specified item.

Namespace:  System.Collections.ObjectModel
Assembly:  mscorlib (in mscorlib.dll)

protected override void SetItem(
	int index,
	TItem item
)

Parameters

index
Type: System.Int32
The zero-based index of the item to be replaced.
item
Type: TItem
The new item.

The lookup dictionary is updated accordingly. That is, the key of the item that is being replaced is removed from the lookup dictionary, and the key of the new item is added.

This method is an O(1) operation.

Notes for Implementers

Override this method to provide customized behavior for setting the Item property inherited from the Collection<T> generic class.

NoteNote:

This method does not affect the behavior of the KeyedCollection<TKey, TItem>.Item property, which is read-only.

Call the base class implementation of this method to set the item in the underlying collection and to update the lookup dictionary.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft