0
不確定這裏有什麼問題,但我想在我創建的接口中使用枚舉。不一致的可訪問性:類中的屬性類型比接口中的屬性類型不易訪問
當我試圖實現我的錯誤
可訪問性不一致的接口:屬性類型「System.Collections.Generic.IList」比財產較少訪問「BusinessEntities.ICloneMessage.AgentAddresses」
枚舉
namespace BusinessEntities
{
public class AddressTypeValues
{
[DataContract(Name = "AddressType")]
public enum AddressType
{
[EnumMember(Value = "Home")]
Home,
[EnumMember(Value = "Mailing")]
Mailing,
[EnumMember(Value = "Location")]
Location,
[EnumMember(Value = "Other")]
Other
}
}
}
接口
namespace BusinessEntities
{
public interface IAgentAddress
{
AddressTypeValues.AddressType AddressType { get; set; }
String? Street1 { get; set; }
String? Street2 { get; set; }
String? Street3 { get; set; }
String? City { get; set; }
String? State { get; set; }
String? ZipCode { get; set; }
}
}
類使用AddresType
namespace BusinessEntities
{
[DataContract]
public class CloneMessage : ICloneMessage
{
[DataMember]
public AgentTransmission AgentInformation { get; set; }
[DataMember]
public IList<AgentAddress> AgentAddresses { get; set; }
[DataMember]
public IList<RelationshipCode> RelationshipCodes { get; set; }
[DataMember]
public string? ErrorMessages { get; set; }
public CloneMessage(){}
}
}
namespace BusinessEntities
{
[DataContract]
public class AgentAddress : IAgentAddress
{
[DataMember]
public AddressTypeValues.AddressType AddressType { get; set; }
[DataMember]
public string Street1 { get; set; }
[DataMember]
public string Street2 { get; set; }
[DataMember]
public string Street3 { get; set; }
[DataMember]
public string City { get; set; }
[DataMember]
public string State { get; set; }
[DataMember]
public string ZipCode { get; set; }
}
}
您的類'AgentAddress'可能是'internal' ,使其成爲公共類 – Habib
如果我這樣做,我被告知我不能在'IAgentAddress'接口中具有可空的'string'屬性。 – NealR
'String'已經是一個可以爲空的類。你不能有一個'Nullable'。刪除問號。 –
Amy