可访问性不一致:属性类型错误
Posted
技术标签:
【中文标题】可访问性不一致:属性类型错误【英文标题】:Inconsistent Accessibility: Property Type Error 【发布时间】:2013-05-30 02:57:44 【问题描述】:我已经完成了谷歌搜索无济于事。这是阻止我的代码编译和运行的唯一错误,但我似乎无法弄清楚。错误的确切文本是“...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>();
【问题讨论】:
AirlinerInsurance的定义是什么?class AirlinerInsurance ..constructors.. public AirlinerInsurance(InsuranceType insType, InsuranceScope insScope, PaymentTerms paymentTerms, int insAmount) ...
所有非int参数都是枚举
【参考方案1】:
这意味着“AirlinerInsurance”类不是公共的。
这是一个公共属性,但允许使用该属性的其他类可能没有对该类本身的访问权限(它是私有的/内部的)。
编辑 现在您已经发布了“AirlinerInsurance”类的代码,只需为其添加“public”修饰符即可。
您可以在here 和here 阅读更多相关信息
【讨论】:
我在你发这个之前就这么做了 :) 谢谢【参考方案2】:你需要
class AirlinerInsurance
// stuff
成为
public class AirlinerInsurance
//stuff
【讨论】:
以上是关于可访问性不一致:属性类型错误的主要内容,如果未能解决你的问题,请参考以下文章
可访问性不一致:字段类型“世界”比字段“frmSplashScreen”更难访问