Solved

Inconsistent accessibility... c#

Posted on 2014-11-18
5
242 Views
Last Modified: 2014-11-18
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

0
Comment
Question by:Mike Eghtebas
  • 2
  • 2
5 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 350 total points
ID: 40450426
Make the Employee class public, right now it is private.

public class Employee
0
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 150 total points
ID: 40450450
right now it is internal.

= )
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40450483
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.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40450498
Not a problem please leave as is seeming I had a minor error in my post.

Thanks kaufmed.
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40451631
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
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now