
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String Formatting in C# to add padding on the right
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
- Related Questions & Answers
- String Formatting in C# to add padding
- CSS padding-right property
- Animate CSS padding-right property
- String Formatting in C# using %
- String Formatting with ToString in C#
- How to add padding to a tkinter widget only on one side?
- Specify the right padding of an element with CSS
- How to set the right padding of an element with JavaScript?
- String Formatting in Python using %?
- String Formatting Operator in Python
- String Formatting in Java using %
- Set the left, right, top and bottom padding of an element
- Number of Larger Elements on right side in a string in C++
- How to convert an integer to string with padding zero in C#?
- MySQL number-string formatting to pad zeros on the left of a string with numbers after a slash
Advertisements