1. arraylist Traversal
Foreach (Object OBJ in mylist) {console. Write ("{0}", OBJ );}
2. hashtable Traversal
For (dictionaryentry de in HT) // HT is a hashtable instance {console. writeline (de. key); // de. the key corresponds to the key/value pair key console. writeline (de. value); // de. key corresponds to key/value Key-Value Pair value}
3. List <t> Traversal
List <string> mylist = new list <string> () foreach (string item in mylist) {console. writelist (item );}
4. dictionary <t, V> Traversal
Dictionary <string, string> openwith = new dictionary <string, string> (); foreach (keyvaluepair <string, string> kVp in openwith) {console. writeline ("Key = {0}, value = {1}", kVp. key, kVp. value);} dictionary <string, string>. valuecollection valuecoll = openwith. values; foreach (string s in valuecoll) {console. writeline ("value = {0}", S );}