Hi, I am learning generics, I want to insert empname, empid and empsalary, I implemented this way

using System;
using System.Collections.Generic;
using System.Text;

namespace EmployeeDetails
{
   public class Emp_Details

   {


         readonly string _EmpName;
         readonly int _EmpId;
         readonly double _EmpSalary;


       public string EmpName
       {
           get
           {
               return _EmpName;
           }
       }
       public int EmpId
       {
           get
           {
               return _EmpId;
           }
       }
       public double EmpSalary
       {
           get
           {
               return _EmpSalary;
           }
       }

    }
    public class GenericClass<T>
    {

        List<Emp_Details> myEmpDetails = new List<Emp_Details>();


    }
    class Program
    {
        static void Main(string[] args)
        {

        }
    }
}

Now I want to read n records, I mean user will input the number of records he wants to enter, and then one by one he will enter the employee details,
Ideas pls and how should I do

First I would suggest that you create a constructor for Emp_Details just to make it easier.

public Emp_Details( string empName, int empId, double empSalary)
{
      _EmpName = empName;
      _EmpId = empId;
      _EmpSalary = empSalary;
}

Then as you get information from the user, and want to enter it into the list you can use this contructor.
Assuming you cature the user input into variables (name, Id and salary)

myEmpDetails.Add( new Emp_Details(name, Id, salary) );

// Jerry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.