Create empty StringCollection in CSharp
Description
The following code shows how to create empty StringCollection.
Example
using System;/*from w w w.j a v a 2 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", "java2s.com"};
myCol.AddRange( myArr );
Console.WriteLine( myCol.Count);
foreach(string s in myCol){
Console.WriteLine(s);
}
}
}
The code above generates the following result.