Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inconsistent accessibility: property type __ is less accessible than property ___

Tags:

c#

I'm creating a database and I need to index the database for all the entries that match a name.

This is where it is being used:

dDatabase.FindAll(findArea.Match);

This is the findArea class:

public class FindArea
{
    string m_Name;
    public FindArea(string name)
    {
        m_Name = name;
    }

    public Predicate<databaseEntry> Match
    {
        get { return NameMatch; }
    }

    private bool NameMatch(databaseEntry deTemp)
    {
        if(deTemp.itemName == m_Name)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

This is the stripped down functionality of the databaseEntry Class:

class databaseEntry
{
    public databaseEntry(int id, int area, string name)
    {
        rfid = id;
        currentArea = area;
        itemName = name;
    }
}

My problem is that when I try to compile this I get

"error CS0053: Inconsistent accessibility: property type 'System.Predicate<Database.databaseEntry>' is less accessible than property Database.FindArea.Match"

in the Predicate<databaseEntry> Match function.

UPDATE

So Thanks for all the help, I needed to set the access of the databaseEntry class to public,

i.e.

public class databaseEntry

or I could have changed the:

public class FindArea

to:

class FindArea

and leave the databaseEntry alone

This happened due to mixing different accessibility for the two classes

like image 671
Cjen1 Avatar asked Mar 18 '23 11:03

Cjen1


1 Answers

Your issue is that your databaseEntry class isn't public and hence for the predicate based on databaseEntry class to be public, you need to also make the databaseEntry class public.

like image 76
rosenKoger Avatar answered Apr 27 '23 21:04

rosenKoger