0

我已经做了谷歌搜索无济于事。这是阻止我的代码编译和运行的唯一错误,但我似乎无法弄清楚。错误的确切文本是“...Dictionary is less access than property 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>();
    }
4

2 回答 2

2

这意味着“AirlinerInsurance”类不是公共的。

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

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

您可以在此处此处阅读有关它的更多信息

于 2013-05-30T03:07:32.403 回答
1

你需要

class AirlinerInsurance {
  // stuff
}

成为

public class AirlinerInsurance {
  //stuff
}
于 2013-05-30T03:10:01.710 回答