c# - 可访问性不一致 : property type __ is less accessible than property ___

标签 c#

我正在创建一个数据库,我需要为数据库中与名称匹配的所有条目建立索引。

这是使用它的地方:

dDatabase.FindAll(findArea.Match);

这是 findArea 类:

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;
        }
    }
}

这是 databaseEntry 类的精简功能:

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

我的问题是,当我尝试编译它时,我得到了

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

Predicate<databaseEntry> Match功能。

更新

所以感谢所有的帮助,我需要将 databaseEntry 类的访问权限设置为 public,

public class databaseEntry

或者我可以改变:

public class FindArea

到:

class FindArea

并单独保留数据库条目

这是由于混合了两个类的不同可访问性而发生的

最佳答案

您的问题是您的 databaseEntry 类不是公开的,因此要使基于 databaseEntry 类的谓词公开,您还需要将 databaseEntry 类设为公开。

关于c# - 可访问性不一致 : property type __ is less accessible than property ___,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27768780/

相关文章:

c# - 将日期时间转换为 C# 中的特定格式

c# - 有没有办法将属性标记为条件

c# - 访问构造函数值

c# - 如何在 NEST C# 中编写动态 Elasticsearch 查询

c# - 在 powerpoint c# 中写入文本

c# - 将 Azure Application Insights 与 Azure WebJob 结合使用

c# - 自动处理 Redis 连接

c# - 确保 Weakreference 在 IsAlive 之后仍然存在

c# - 从 wpf 中的其他窗口更改框架源

c# - 如何使用 C#.Net 中的 LDAP 在 Windows 事件目录中获取组织单位的街道地址属性