Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Adds an entry with the specified key and value into the ListDictionary

using System; using System.Collections; using System.Collections.Specialized; public class SamplesListDictionary  {    public static void Main()  {       ListDictionary myCol = new ListDictionary();       myCol.Add( "A", "1.49" );       myCol.Add( "B", "1.29" );       myCol.Add( "C", "0.99" );       PrintKeysAndValues( myCol );       myCol.Remove( "A" );       PrintKeysAndValues( myCol );       myCol.Clear();       PrintKeysAndValues( myCol );    }    public static void PrintKeysAndValues( IDictionary myCol )  {       foreach ( DictionaryEntry de in myCol )          Console.WriteLine( "   {0,-25} {1}", de.Key, de.Value );    } }