[DataContract]
public class OrderSyncData : ISync
{
public OrderSyncData(Order o)
{
this.CurrentOrderStatus = o.DriverStatus;
this.StatusDescription = o.StatusDescription;
SyncTimestamp = o.SyncTimestamp; ????
}
[DataMember]
public string CurrentOrderStatus { get; set; }
[DataMember]
public string StatusDescription { get; set; }
[DataMember]// I don't think I need these any more
public bool IsCanceled { get; set; }
[DataMember]
public bool IsResolved { get; set; }
[DataMember]
public bool IsPendingResponse { get; set; }
DateTime ISync.SyncTimestamp { get; set; }
}
如何设置ISync.SyncTimestamp的值?我试着类型转换“这个”。但它不起作用
最佳答案
这应该有效:
((ISync)this).SyncTimestamp = o.SyncTimestamp;
请注意 (ISync)this
周围的额外大括号。
关于c# - 如何在构造函数中设置属性值(显式接口(interface)实现),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14882141/