test_hashtable2.htm
Using
  • sortedlist.Add("1", "=Jan"); method
  • ICollection c = sortedlist.Keys;
  • for-each loop ... sortedlist[str1])
  • DictionaryEntry
 
Code Used :

// Namespace Declaration
//File location : C:\BareBone_CSharp\Source_Code\Template
using System;
//csc test_hastable2.cs
using System.Collections;
// Program start class
namespace test_hastable2
{

class CsharpTemplate
{
// Main begins program execution.
public static void Main(string[] str)
{
Hashtable hashtable = new Hashtable();
hashtable.Add("1", "=Jan");
hashtable.Add("2","=Feb");
hashtable.Add("3","=Mar");
ICollection c =hashtable.Keys;
Console.WriteLine("Using foreach Icolection ");
foreach(string str1 in c)
{
Console.WriteLine(str1 + ":"+ hashtable[str1]);
}
Console.WriteLine("Using foreach DictionaryEntry");
foreach (DictionaryEntry entry in hashtable)
{
Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
}
}
}
}
//