Zhi Wee
Zhi Wee

Reputation: 45

Inconsistent accessibility: field type 'System.Collections.Generic.Dictionary<> is less accessible than other field

[Serializable]
class LotInfo
{
    public int ID { get; set; }
    public string DonorName { get; set; }
    public string BloodGroup { get; set; }
    public string RhFactor { get; set; }
    public string Address { get; set; }
    public string TelephoneNumber { get; set; }

    public LotInfo(int id)
    {
        ID = id;
    }

    public LotInfo()
    {

    }
}

[Serializable]
public class LotInfoDatabase
{
    public Dictionary<int, LotInfo> dicLotDatabase = new Dictionary<int, LotInfo>();
    public int LastID { get; set; }
    public int GetNewID()
    {
        return (++LastID);
    }
}

Guys, I am doing Serializer for datagridview for saving and loading the data. But this error comes...

Inconsistent accessibility: field type 'System.Collections.Generic.Dictionary' is less accessible than field 'Blood_Bank_Management.LotInfoDatabase.dicLotDatabase'

Im new to stackoverflow, please forgive me if I've did any wrong. Thanks...

Upvotes: 3

Views: 4746

Answers (1)

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239724

LotInfo is an internal class, rather than public, because you've not specified any modifier for it.

But then you construct a type Dictionary<int, LotInfo> and try to expose it via a public field (dicLotDatabase) on a public type (LotInfoDatabase). Making LotInfo public would be one way to fix this problem, but I'm not sure if it's what you want to do.

Upvotes: 6

Related Questions