Display the contents of the collection using foreach. This is the preferred method
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" ); Console.WriteLine( "Displays the elements using foreach:" ); 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(); } }