Monday, April 18, 2011

String.PadLeft Method

Returns a new string of a specified length in which the beginning of the current string is padded with spaces or with a specified Unicode character.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.


PadLeft(Int32) Returns a new string that right-aligns the characters in this instance by padding them with spaces on the left, for a specified total length.
PadLeft(Int32, Char)    Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a specified total length.
Example :- 1.ToString().PadLeft(4,'0')
Will show the results as "0001"
Source : -http://msdn.microsoft.com/en-us/library/system.string.padleft.aspx

No comments:

Post a Comment