Progress Monitor for IdealProgrammer.com
Take Swift, Intelligent, Massive, Planned, Loving, Effective (S.I.M.P.L.E.) Action to Transform Self into Ideal
Skip Repetitive Navigational Links
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console
Please login
C-Sharp PadLeft Example Syntax - C# String Function - Sample Code
Description:
Illustrates the C# Syntax for PadLeft.
Example Class Main:
using System; public class clsPadLeft { public void Main() { //**************************************************************************************** // Example #1: PadLeft(totalWidth [, paddingCharacter]) // Returns a string that is right-aligned and padded on left with character specified. // If no padddingCharacter is specified, space is used. totalWidth is total width of column // This allows you to create a nice straight column even though lengths of text vary. //**************************************************************************************** Console.WriteLine("Example #1: PadLeft(totalWidth [, paddingCharacter]) "); string strPadLeftExampleA = "This is a test string"; string strPadLeftExampleB = "short"; string strPadLeftExampleC = "longer"; // PadLeft "simple" before "test" Console.WriteLine(strPadLeftExampleA.PadLeft(35)); Console.WriteLine(strPadLeftExampleB.PadLeft(35)); Console.WriteLine(strPadLeftExampleC.PadLeft(35)); //write blank line to make output easier to read Console.WriteLine(); //Prevent console from closing before you press enter Console.ReadLine(); } }
Example Class Program:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CSharp_Syntax { class Program { static void Main(string[] args) { clsPadLeft myPadLeft = new clsPadLeft(); myPadLeft.Main(); } } }
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console