Solved

Inconsistent accessibility... c#

Posted on 2014-11-18
5
262 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 63

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 75

Assisted Solution

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

= )
0
 
LVL 75

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 63

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 34

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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