c# – 如何在构造函数中设置属性值(显式接口实现)

c# – 如何在构造函数中设置属性值(显式接口实现),第1张

概述[DataContract]public class OrderSyncData : ISync{ public OrderSyncData(Order o) { this.CurrentOrderStatus = o.DriverStatus; this.StatusDescription = o.StatusDescription;
[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).

总结

以上是内存溢出为你收集整理的c# – 如何在构造函数中设置属性值(显式接口实现)全部内容,希望文章能够帮你解决c# – 如何在构造函数中设置属性值(显式接口实现)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1249869.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-07
下一篇2022-06-07

发表评论

登录后才能评论

评论列表(0条)

    保存