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

StackOverflow https://stackoverflow.com/questions/23535420

  •  17-07-2023
  •  | 
  •  

Domanda

[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...

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top