Check if a SortedList object contains a specific key in CSharp
Description
The following code shows how to check if a SortedList object contains a specific key.
Example
using System;// ww w. j a v a 2 s . c o m
using System.Collections;
public class SamplesSortedList {
public static void Main() {
SortedList mySL = new SortedList();
mySL.Add( 2, "two" );
mySL.Add( 4, "four" );
mySL.Add( 1, "one" );
mySL.Add( 3, "three" );
mySL.Add( 0, "zero" );
int myKey = 2;
Console.WriteLine(mySL.ContainsKey( myKey ));
}
}
The code above generates the following result.