首页 > 编程语言 > 详细

对象自定义排序

时间:2019-08-29 11:04:05      阅读:91      评论:0      收藏:0      [点我收藏+]
public class JSForm: IComparer<JSForm>, IComparable<JSForm>
    {
        [Key]
        [Required]
        public int ID { get; set; }

        [Required]
        public string RowGuid { get; set; } 

        public int IsDelete { get; set; }

        [Required]
        public string SendNumber { get; set; } //发货编号
        public string ClientRowGuid { get; set; }//客户RowGuid
        public string ClientAddress { get; set; }//客户地址
        public string ClientName { get; set; }//客户名称
        public string ClientContactUser { get; set; }//客户联系人

        public string SendDate { get; set; } //发货日期    

        public string WuLiuName { get; set; } //物流名称

        public string WuLiuRowGuid { get; set; }

        public string WuLiuNumber { get; set; }

        public string CashCharge { get; set; } //现付费用
        public string CashChargeDesc { get; set; } //对方付,我方付
        public string SelfCharge { get; set; } // 自提费用

        public string WuLiuUnitPrice { get; set; }

        public string BucketStyle { get; set; } //销桶,返桶,自带桶
        public string BucketCount { get; set; }
        public string BucketPrice { get; set; }
        public string BucketSumPrice { get; set; }

        public string ActPay { get; set; } //实付
        public string Manager { get; set; }

        public string SettlementModel { get; set; } //结算方式
        public string IsNote { get; set; } //是否开票
        public string IsContract { get; set; } //是否合同

        public string Description { get; set; }

        public int Compare(JSForm j1, JSForm j2)
        {
            string sn1 = j1.SendNumber.Substring(4);
            string sn2 = j2.SendNumber.Substring(4);
            long v1 = Convert.ToInt64(sn1);
            long v2 = Convert.ToInt64(sn2);
            if (v1 > v2)
                return 1;
            if (v1 < v2)
                return -1;
            return 0;
        }

        public int CompareTo(JSForm js)
        {
            return Compare(this, js);
        }

    }

  

对象自定义排序

原文:https://www.cnblogs.com/wangzuofei/p/11428005.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!