स्ट्रिंग के दाईं ओर पैडिंग जोड़ने के लिए -
const string format = "{0,10}"; अब इसे स्ट्रिंग में जोड़ें -
string str1 = string.Format(format, "Marks","Subject");
आइए देखें पूरा कोड -
उदाहरण
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);
}
} आउटपुट
Marks 95