Hi guys
I have a class like following
- class Employees
- {
- string empName;
- string deptName;
- double salary;
- double bonus;
-
- public Employees(string eName, string dName, double eSalary, double eBonus)
- {
- this.empName = eName;
- this.deptName = dName;
- this.salary = eSalary;
- this.bonus = eBonus;
-
- }
- }
and in my main method I am trying to create a List using the class like following:
- class TestGenericList
- {
- static void Main()
- {
- List myList = new List();
-
- Employees rajesh = new Employees("Rajesh Thampi", "IT", 1125.000, 300.000);
- myList.Add(rajesh);
-
- foreach (Employees obj in myList)
- {
- Console.WriteLine(obj);
- }
-
-
- }
- }
How do you I print each element from the list object at the console?
I want to print the output like this
Console.WriteLine("Employee Name: {0}, Department: {1}, Salary: {2}, Bonus: {3}", ?, ?, ?, ?);
I am totally outta clue here. Please help :)