Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Inconsistent accessibility... c#

Posted on 2014-11-18
5
Medium Priority
?
301 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 64

Accepted Solution

by:
Fernando Soto earned 1400 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 600 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 64

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses

877 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