Cjen1
Cjen1

Reputation: 1746

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

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

Upvotes: 4

Views: 11802

Answers (2)

LongDev
LongDev

Reputation: 221

your interface is public but still error , so trying to check if there 's any type of property in that interface but it is private like this

    public interface IResult<out T>
    {
        bool Success { get; }
        T Value { get; }
        ResultInfo Info { get; }

    }


but the ResultInfo class is internal

so you need to make ResultInfo class to be public

Upvotes: 0

rosenKoger
rosenKoger

Reputation: 96

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.

Upvotes: 8

Related Questions