C# SortedList SetByIndex
Description
SortedList SetByIndex
replaces the value at a specific
index in a SortedList object.
Syntax
SortedList.SetByIndex
has the following syntax.
public virtual void SetByIndex(
int index,
Object value
)
Parameters
SortedList.SetByIndex
has the following parameters.
index
- The zero-based index at which to save value.value
- The Object to save into the SortedList object. The value can be null.
Returns
SortedList.SetByIndex
method returns
Example
The following code example shows how to replace the value of an existing element in a SortedList object.
// ww w . j ava 2 s .c o m
using System;
using System.Collections;
public class SamplesSortedList {
public static void Main() {
SortedList mySL = new SortedList();
mySL.Add( 2, "two" );
mySL.Add( 3, "three" );
mySL.Add( 1, "one" );
mySL.Add( 0, "zero" );
mySL.Add( 4, "four" );
mySL.SetByIndex( 3, "III" );
}
}
The code above generates the following result.