Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Related to Question at:
- //http://groups.google.com/group/dotnetdevelopment/browse_thread/thread/d76ad9d3f6a811fb
- // Uses the foreach statement which hides the complexity of the enumerator.
- // NOTE: The foreach statement is the preferred way of enumerating the contents of a collection.
- public static void PrintKeysAndValues1( ShortStringDictionary myCol ) {
- foreach ( DictionaryEntry myDE in myCol )
- Console.WriteLine( " {0,-5} : {1}", myDE.Key, myDE.Value );
- Console.WriteLine();
- }
- // Uses the enumerator.
- // NOTE: The foreach statement is the preferred way of enumerating the contents of a collection.
- public static void PrintKeysAndValues2( ShortStringDictionary myCol ) {
- DictionaryEntry myDE;
- System.Collections.IEnumerator myEnumerator = myCol.GetEnumerator();
- while ( myEnumerator.MoveNext() )
- if ( myEnumerator.Current != null ) {
- myDE = (DictionaryEntry) myEnumerator.Current;
- Console.WriteLine( " {0,-5} : {1}", myDE.Key, myDE.Value );
- }
- Console.WriteLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment