Program for Array List in C Sharp

using System;

using System.Collections;

public class Employee

{

    public int EmpId {get; set;}

    public string EmpName {get; set;}

    static void Main()

    {

        ArrayList firstEmp = new ArrayList();

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

        firstEmp.Add(new Employee(){EmpId=102,EmpName=”Rajan”});

        foreach(object e in firstEmp)

        {

            Employee currentEmployee = (Employee)e;

            Console.WriteLine(“Employee ID:{0},Employee Name:{1}”, currentEmployee.EmpId, currentEmployee.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.