Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Adds a string to the end of the StringCollection

using System; using System.Collections; using System.Collections.Specialized; public class SamplesStringCollection  {    public static void Main()  {       StringCollection myCol = new StringCollection();       PrintValues( myCol );              String[] myArr = new String[] { "a", "o"};       myCol.AddRange( myArr );              PrintValues( myCol );              myCol.Add( "w" );       myCol.Insert( 3, "g" );              PrintValues( myCol );    }    public static void PrintValues( IEnumerable myCol )  {       foreach ( Object obj in myCol )          Console.WriteLine( "   {0}", obj );    } }