WCF 新手。
DataContact 类可以继承自 Interface 吗?
例如:
[DataContract(Namespace = ...........)]
public class VesselSequence : IVesselSequence
{
[DataMember]
public int AllocationId { get; set; }
[DataMember]
public string ScenarioName { get; set; }
}
interface VesselSequence : IVesselSequence
{
public int AllocationId { get; set; }
public string ScenarioName { get; set; }
}
最佳答案
你可以这样做:
[DataContract(Namespace = ...........)]
public class VesselSequence : IVesselSequence
{
[DataMember]
public int AllocationId { get; set; }
[DataMember]
public string ScenarioName { get; set; }
}
interface IVesselSequence
{
int AllocationId { get; set; }
string ScenarioName { get; set; }
}
遗憾的是,你不能这样做:
public class VesselSequence : IVesselSequence
{
public int AllocationId { get; set; }
public string ScenarioName { get; set; }
}
[DataContract(Namespace = ...........)]
interface IVesselSequence
{
[DataMember]
int AllocationId { get; set; }
[DataMember]
string ScenarioName { get; set; }
}
关于c# - WCF DataContract 与 DataContract 接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1090736/