![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# String.PadLeft Method
Pad the beginning of the string with spaces using the PadLeft() method. You can also pad it with a Unicode character.
Let’s say the following is our string.
string myStr = "DemoOne";
To set a padding at the beginning of the above string, use the PadLeft method.
myStr.PadLeft(10);
Here is the complete example.
Example
using System; class Demo { static void Main() { string myStr = "DemoOne"; // set padding at the beginning Console.WriteLine(myStr.PadLeft(10)); myStr = "DemoTWO"; // set padding at the beginning Console.Write(myStr.PadLeft(15)); } }
Output
DemoOne DemoTWO
Advertisements