对象自定义排序

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
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值