To format a string, first set the value −
int value = 55;
Now to format the integer, use ToString and let’s say we need to set it for three places −
value.ToString("000");The following is the complete code −
Example
using System;
public class Program {
public static void Main() {
int value = 55;
string res = value.ToString("000");
Console.WriteLine(res);
}
}Output
055