String: PadLeft/Right with character : String Pad Trim « String « C# / CSharp Tutorial






using System;  
  
class MainClass {  
  public static void Main() {  
    string str = "     test    "; 
 
    Console.WriteLine("Original string:" + str+"<"); 
     
    // Pad on left with #s. 
    str = str.PadLeft(10, '#'); 
    Console.WriteLine("|" + str + "|"); 
 
    // Pad on right with #s. 
    str = str.PadRight(20, '#'); 
    Console.WriteLine("|" + str + "|"); 
 
  } 
}
Original string:     test    <
|     test    |
|     test    #######|








5.16.String Pad Trim
5.16.1.String PadLeft and PadRight
5.16.2.String: trim
5.16.3.String: PadLeft/Right with character
5.16.4.String: Pad on right with #s
5.16.5.String: Trim #s
5.16.6.Trimming a string: trim start, trim end and trim chars