Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

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.Employee)'      

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of Mike Eghtebas

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