Hi,

I came across a doubt on the String.PadLeft Method.The doubt is this --
What's difference it make if the argument to this function carries an
integer whose value is less than the length of the string object

For example in the sample code below(VB.NET) I could not see any difference



Dim str As String
str = "BBQ and Slaw"
Console.WriteLine(str.PadLeft(5)) ' Displays "BBQ and Slaw".

Console.WriteLine(str.PadLeft(15)) ' Displays " BBQ and Slaw".

I could not notice any difference with the output of str.PadLeft(5) and
the original str string.Both carries the same message "BBQ and Slaw"

Can any one tell me what is the use of this particular function if the
padleft paramater is less than the length of the string.

Reny

Re: PadLeft - What difference it make if the argument to this function carries an integer whose value is less than the length of the string object by Kevin

Kevin
Tue May 09 07:57:30 CDT 2006

> Can any one tell me what is the use of this particular function if the
> padleft paramater is less than the length of the string.

None. It is used to add padding to a string that is shorter than the number
passed. If a string is longer, it doesn't need any padding.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Reny" <reny@bxtech.com> wrote in message
news:enpreZ2cGHA.4932@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I came across a doubt on the String.PadLeft Method.The doubt is this --
> What's difference it make if the argument to this function carries an
> integer whose value is less than the length of the string object
>
> For example in the sample code below(VB.NET) I could not see any
> difference
>
>
>
> Dim str As String
> str = "BBQ and Slaw"
> Console.WriteLine(str.PadLeft(5)) ' Displays "BBQ and Slaw".
>
> Console.WriteLine(str.PadLeft(15)) ' Displays " BBQ and Slaw".
>
> I could not notice any difference with the output of str.PadLeft(5) and
> the original str string.Both carries the same message "BBQ and Slaw"
>
> Can any one tell me what is the use of this particular function if the
> padleft paramater is less than the length of the string.
>
> Reny
>
>
>
>
>