Avatar of Mike Eghtebas
Mike Eghtebas
Flag 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

C#.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Mike Eghtebas

8/22/2022 - Mon