In C#, there are properties so you shouldn't write get/set methods. Assuming your employee class currently looks like this:
class Employee { private string name; public string getName() { return this.name; } public string setName(string name) { this.name = value; }}
...you could do this instead:
// C#2:class Employee { private string name; public string Name { get { return this.name; } set { this.name = value; } }}// C#3: (If you don't do any error checking on Name)class Employee { public string Name { get; set; }}
To the question in hand, you can do something a little more elegant (hard-coded to delete John here):
// C#2:Employees.RemoveAll(delegate(Employee E) { return E.Name == "John" && MessageBox.Show("Delete?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes; });// C#3:Employees.RemoveAll(E => E.Name == "John" && MessageBox.Show("Delete?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes);