可访问性不一致:属性类型错误

时间:2013-05-30 02:57:45

标签: c#

我做了谷歌搜索无济于事。这是阻止我的代码编译和运行的唯一错误,但我似乎无法弄明白。错误的确切文本是“...字典不如属性FleetAirliner.InsuranceProperties”

任何可能导致这种情况的想法?

namespace TheAirline.Model.AirlinerModel
{
[Serializable]
public class FleetAirliner
{
    public Airliner Airliner { get; set; }
    public string Name { get; set; }
    public Airport Homebase { get; set; }
    public enum PurchasedType { Bought, Leased,BoughtDownPayment }
    public DateTime PurchasedDate { get; set; }
    public PurchasedType Purchased { get; set; }
    public Boolean HasRoute { get { return this.Routes.Count > 0; } set { ;} }
    public AirlinerStatistics Statistics { get; set; }

    /*Changed for deleting routeairliner*/
    public enum AirlinerStatus { Stopped, On_route, On_service, Resting, To_homebase, To_route_start }
    public AirlinerStatus Status { get; set; }
    public Coordinates CurrentPosition { get; set; }
    public List<Route> Routes { get; private set; }
    public Flight CurrentFlight { get; set; }
    public DateTime GroundedToDate { get; set; }
    public List<Pilot> Pilots { get; set; }
    public Dictionary<string, AirlinerInsurance> InsurancePolicies { get; set; } //error occurs here
    public int NumberOfPilots {get {return this.Pilots.Count;} private set {;}}
    public FleetAirliner(PurchasedType purchased,DateTime purchasedDate, Airline airline,Airliner airliner,Airport homebase)
    {
        this.Airliner = airliner;
        this.Purchased = purchased;
        this.PurchasedDate = purchasedDate;
        this.Airliner.Airline = airline;
        this.Homebase = homebase;
        this.Name = airliner.TailNumber;
        this.Statistics = new AirlinerStatistics(this);

        this.Status = AirlinerStatus.Stopped;

        this.CurrentPosition = new Coordinates(this.Homebase.Profile.Coordinates.Latitude, this.Homebase.Profile.Coordinates.Longitude);

        this.Routes = new List<Route>();
        this.Pilots = new List<Pilot>();
        this.InsurancePolicies = new Dictionary<string, AirlinerInsurance>();
    }

2 个答案:

答案 0 :(得分:2)

这意味着班级“AirlinerInsurance”不公开。

这是一个公共属性,但允许使用该属性的其他类可能没有对该类本身的访问权限(它是私有/内部的)。

修改 现在您已经发布了“AirlinerInsurance”类的代码,只需添加一个“公共”修饰符即可。

您可以详细了解herehere

答案 1 :(得分:1)

你需要

class AirlinerInsurance {
  // stuff
}

public class AirlinerInsurance {
  //stuff
}