PadLeft()函数:向左补齐
PadRight()函数:向右补齐

 class Program
    {
        static void Main(string[] args)
        {
            int a = 3;
            Console.WriteLine(a.ToString().PadLeft(3,'0'));   //向左补齐
            Console.WriteLine(a.ToString().PadRight(3, '0')); //向右补齐
            Console.ReadKey();
        }
    }

C#数字前面如何补0

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-06-07
  • 2021-07-30
相关资源
相似解决方案