Remove the first occurrence of a specific string from the StringCollection in CSharp
Description
The following code shows how to remove the first occurrence of a specific string from the StringCollection.
Example
using System;/*w w w . j a v a2 s. c o 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 );
myCol.Remove( "A" );
foreach ( Object obj in myCol ){
Console.WriteLine( obj );
}
}
}
The code above generates the following result.