This documentation is archived and is not being maintained.

StringCollection.Item Property

Gets or sets the element at the specified index.

[C#] In C#, this property is the indexer for the StringCollection class.

[Visual Basic]
Public Default Property Item( _
   ByVal index As Integer _
) As String
public string this[
 int index
] {get; set;}
public: __property String* get_Item(
 int index
public: __property void set_Item(
 int index,
returnValue = StringCollectionObject.Item(index);
StringCollectionObject.Item(index) = returnValue;
returnValue = StringCollectionObject(index);
StringCollectionObject(index) = returnValue;

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed property whose type is Object and whose index type is String.

Arguments [JScript]

The zero-based index of the entry to get or set.

Parameters [Visual Basic, C#, C++]

The zero-based index of the entry to get or set.

Property Value

The element at the specified index.


Exception Type Condition
ArgumentOutOfRangeException index is less than zero.


index is equal to or greater than Count.


This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

StringCollection accepts a null reference (Nothing in Visual Basic) as a valid value and allows duplicate elements.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

StringCollection Class | StringCollection Members | System.Collections.Specialized Namespace | Count