Check if the specified string is in the StringCollection in CSharp
Description
The following code shows how to check if the specified string is in the StringCollection.
Example
using System;/*from ww w .ja v a 2 s. co m*/
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringCollection {
public static void Main() {
StringCollection myCol = new StringCollection();
String[] myArr = new String[] { "A", "B", "C" };
myCol.AddRange( myArr );
Console.WriteLine(myCol.Contains( "A" ) );
}
}
The code above generates the following result.