Convert.ToInt32(string '000000003') 变成了 3

Convert.ToInt32(string '000000003') 变成了 3

但是在查询的时候需要用的是string 这里的convert.toint32 反而起了坏作用,不是所有的时候都要用convert,

  public int InvalidEntry(FormCollection collection)
        {
            int startNumber = Convert.ToInt32(collection["StartNumber"]);
            int endNumber = Convert.ToInt32(collection["EndNumber"]);
            DateTime refundDate = Convert.ToDateTime(collection["RefundDate"]);
            string refundRemark = collection["RefundRemark"];
            int number = endNumber - startNumber;
            if (number > -1)
            {
                int result = 0;
                for (int i = startNumber; i <= endNumber; i++)
                {
                    InvoiceInfor invoiceInforerror = this.OMService.GetInvoiceInforDetailByNumber(Convert.ToString(i).PadLeft(8, '0'));
                    //1为未开
                    if (invoiceInforerror.Status == (int)EnumInvoiceInforStatus.NotOpen)
                    {
                        invoiceInforerror.Status = (int)EnumInvoiceInforStatus.Invalid;//三为废票
                        invoiceInforerror.Remark = "该票是废票,缘由:" + refundRemark;
                        invoiceInforerror.BillingDate = refundDate;
                        invoiceInforerror.Biller = this.UserContext.LoginInfo.UserName;
                        invoiceInforerror.RefundMoney = 0;
                        if (this.OMService.SaveInvoiceInfor(invoiceInforerror))
                        {
                            //录入废票日志
                            string context = "录入废票;废票ID:" + invoiceInforerror.ID + ";错票号码:" + invoiceInforerror.Number + ";错票缘由:" + invoiceInforerror.Remark;
                            this.OMService.SaveOMLog(2, "InvoiceInfor", invoiceInforerror.ID, context, this.UserContext.LoginInfo.UserID, this.UserContext.LoginInfo.UserName,0);
                            result = 0;
                        }
                        else
                        {
                            //保存失败
                            result = 2;
                        }
                    }
                    else
                    {
                        result = 3;
                    }
                }
                return result;
            }
            else
            {
                //截止号码必须大于或等于起始号码
                return 1;
            }

        }
原文地址:https://www.cnblogs.com/zhaokunbokeyuan256/p/6477564.html