我希望将数字都转换为8位的字符串,如果不够8位,则前面追加0
比如1转化为'00000001'
231转化为'00000231'
有现成的函数没,没找到,谢了~~

解决方案 »

  1.   

    楼主可以这样:以下是一个控制台程序,
    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                decimal dec = decimal.Parse("231");
                Console.Write(dec.ToString("00000000"));        }
        }
    }
    是可以达到楼主想要的效果的
      

  2.   

    谢谢catvv
    原来这么简单 -_-
      

  3.   

    int i = 1;
    Console.WriteLine(i.ToString().PadLeft(8,'0'));
      

  4.   

            public static String ToUniformString(Object Value, Int16 Len, char C)
            {
                string s = (new string(C, Len) + Value.ToString());
                return s.Substring(s.Length - Len);
            }