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);
- }
- }
- }
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 :)

Ankit SharmaRank #141 · 16.1K reputationPosted Oct 31, 2017, 11:55 PM EDT
Rajesh Thampi9 reputationPosted Nov 1, 2017, 12:05 AM EDT
Ankit SharmaRank #141 · 16.1K reputationPosted Nov 1, 2017, 12:14 AM EDT