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

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

  •  17-07-2023
  •  | 
  •  

문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top