WCF新手。
DataContact类可以从接口继承吗?
例如:
[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; }
}发布于 2012-10-07 01:03:55
您可以这样做:
[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; }
}发布于 2009-07-07 06:54:11
当然可以,但请记住,如果您要返回接口类型,则必须为反序列化引擎定义KnownTypes属性,这样它就可以在另一端反序列化您发送的接口。
https://stackoverflow.com/questions/1090736
复制相似问题