Mega Code Archive

 
Categories / C# / Collections Data Structure
 

ListDictionary Class implements IDictionary using a singly linked list

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" );       PrintKeysAndValues1( myCol );    }    public static void PrintKeysAndValues1( IDictionary myCol )  {       Console.WriteLine( "   KEY                       VALUE" );       foreach ( DictionaryEntry de in myCol )          Console.WriteLine( "   {0,-25} {1}", de.Key, de.Value );       Console.WriteLine();    }     }