To add padding on the right to a string −
const string format = "{0,10}";Now add it to the string −
string str1 = string.Format(format, "Marks","Subject");
Let us see the complete code −
Example
using System;
public class Program {
public static void Main() {
// set right padding
const string format = "{0,10}";
string str1 = string.Format(format, "Marks","Subject");
string str2 = string.Format(format, "95","Maths");
Console.WriteLine(str1);
Console.WriteLine(str2);
}
}Output
Marks 95