Number formatting: how to convert 1 to “01”, 2 to “02”, etc.? March 22, 2023 by Tarik Here is the MSDN article on formatting numbers. To pad to 2 digits, you can use: n.ToString("D2")