substring('13255',0,2)得13
substring('13255',2,3)得255
不足位补0要看你在什么地方显示了一般是‘0’+substring('13255',0,2)中间加个判断就OK了

解决方案 »

  1.   

    string strValue = string.Format("{0:d10}", icust_id);
      

  2.   

    如:
    int32 icust_id=123;
    string strValue = string.Format("{0:d10}", icust_id);
    //strValue的值为:"0000000123"
      

  3.   

    for (int i=0;i<Key.Length;i++)
    {
    CryptKey+=string.Format("{0:d10}",Key[i].ToString());
    }
    为什么在这个CryptKey中那些0全没了?
      

  4.   

    CryptKey+=string.Format("{0:d10}",Key[i]);don't use tostring()! {0:d10} only for numberuse this:string s ="123";
    int mustLength = 6; //定义长度
    string str = new String('0',mustLength-s.Length) + s;
    MessageBox.Show(str);
      

  5.   

    string s ="123";
    int mustLength = 6; //定义长度
    string str = s.PadLeft(mustLength,'0');
    MessageBox.Show(str);