When I click a button I want a message box to pop up with the employee with the lowest salary. These employees are inputted via textboxes and stored in array. The class is called “Employee”.
I’ve gotten it to work but for example if I entered ID: 1234, firstname: Bob, lastname: Styles, Salary: 24, the messagebox displays : “1234BobStyles24” with no spaces. How can I fix this? Here’s my code:
private void lowestSalaryButton_Click(object sender, EventArgs e)
{
decimal minSalary = employees.Min(em => em.YearSalary);
IEnumerable<Employee> poors = employees.Where(em => em.YearSalary == minSalary);
poors.Count();
foreach (var poor in poors)
MessageBox.Show(minSalary.ToString("C") + poor.FirstName + poor.LastName +
poor.EmployeeId, "Min salary");
}
}
}
Just change it to this :
Or a better way would be :