Program for Hashtable in C Sharp

using System;

using System.Collections;

using System.Collections.Generic;

class Employee


    public int EmpId;

    public string EmpName;

    public static void Main()


       Hashtable AnyEmployee = new Hashtable();

        AnyEmployee.Add(1, new Employee(){EmpId=101, EmpName = “Shubham”});

        AnyEmployee.Add(2, new Employee(){EmpId=102, EmpName=”Ankit”});

       Employee e = (Employee)AnyEmployee[2]; // FOUCS ON SYNTAX

        /*If I put 1 in [] bracket,then it will print  Employee Id:101, Employee Name:Shubham*/

        Console.WriteLine(“Employee Id:{0}, Employee Name:{1}”,

                          e.EmpId, e.EmpName);



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.