Mike Eghtebas
asked on
Inconsistent accessibility... c#
In a practice, I have built the following to search for Employee.ID=102. I am getting an error at line 27
public static bool FindEmployee(Employee emp) stating:
Inconsistent accessibility: parameter type 'lambda.Employee' is less accessible than method 'lambda.Form1.FindEmployee (lambda.Em ployee)'
Question: How can I correct this?
public static bool FindEmployee(Employee emp) stating:
Inconsistent accessibility: parameter type 'lambda.Employee' is less accessible than method 'lambda.Form1.FindEmployee
Question: How can I correct this?
namespace lambda
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
List<Employee> listEmployees = new List<Employee>()
{
new Employee{ID = 101, Name = "Mark"},
new Employee{ID = 102, Name = "John"},
new Employee{ID = 103, Name = "Mary"},
};
// STEP 2
Predicate <Employee> employeePeridicate = new Predicate<Employee>(FindEmployee);
// STEP 3
Employee employee = listEmployees.Find(emp => FindEmployee(emp));
MessageBox.Show(employee.ID.ToString() + ", " + employee.Name.ToString());
}
// STEP 1
public static bool FindEmployee(Employee emp)
{
return emp.ID == 102;
}
}
}
//
namespace lambda
{
class Employee
{
public int ID { get; set; }
public string Name { get; set; }
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I appreciate the gesture, but I would humbly suggest allocating all of the points to Fernando. His is the correct answer; I was just clarifying a minor detail.
Not a problem please leave as is seeming I had a minor error in my post.
Thanks kaufmed.
Thanks kaufmed.
ASKER
kaufmed,
Your input did enhanced the response. Both of you have been generous and helpful with you comments on my question which is greatly appreciated.
Mike
Your input did enhanced the response. Both of you have been generous and helpful with you comments on my question which is greatly appreciated.
Mike