Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Collection.RemoveItem Method

Removes the element at the specified index of the Collection.

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

protected:
virtual void RemoveItem (
	int index
)
protected void RemoveItem (
	int index
)
protected function RemoveItem (
	index : int
)
Not applicable.

Parameters

index

The zero-based index of the element to remove.

Exception typeCondition

ArgumentOutOfRangeException

index is less than zero.

-or-

index is equal to or greater than Count.

This method is an O(n) operation, where n is Count.

The following code example shows how to derive a collection class from a constructed type of the Collection generic class, and how to override the protected InsertItem, RemoveItem, ClearItems, and SetItem methods to provide custom behavior for the Add, Insert, Remove, and Clear methods, and for setting the Item property.

The custom behavior provided by this example is a Changed notification event that is raised at the end of each of the protected methods. The Dinosaurs class inherits Collection<string> (Collection(Of String) in Visual Basic) and defines the Changed event, which uses a DinosaursChangedEventArgs class for the event information, and an enumeration to identify the kind of change.

The code example calls several properties and methods of Collection to demonstrate the custom event.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft