473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

String.PadLeft Method

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
May 10 '06 #1
2 7224
md
http://www.google.com/search?hl=en&q...=Google+Search

Matt

"Reny" <re**@bxtech.com> wrote in message
news:%2****************@TK2MSFTNGP04.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

May 10 '06 #2
How is this behavior not consistant with the documentation?

"Right-aligns the characters in this instance, padding on the left with
spaces or a specified Unicode character for a specified total length. "

If the size was < the length there would be no padding to perform.

Cheers,

Greg Young

"Reny" <re**@bxtech.com> wrote in message
news:%2****************@TK2MSFTNGP04.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

May 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jac | last post by:
Hey, I have an int32 and a string. The integer contains : 56 I want to fill up the string as follows : "00056" The string must have a lenght of 5 en must be filled up with leading zero's....
5
by: ywchan | last post by:
I would like to convert a string to a fixed length e.g. if fixed length = 10 'abc' -> ' abc' 'abcdefghijklm' -> 'abcdefghij' Is there any simple function in C# can perform this operation?...
3
by: Locia | last post by:
I have a Template base class and another subclasses of Template. I have a tree structure of template object. class Template { ArrayList child; public virtual String Eval(Environment env) {
15
by: JenHu | last post by:
Hi expert, I have a data field (birthdate) contains a datetime datatype (mm/dd/yyyy), how can I convert to mmdd?? say, the birthday is 8/1/1979 and convert to mmdd DOB =...
6
by: gdjoshua | last post by:
New to C##.. All I want to do is add spaces to a string I'm displaying in label? Anybody know the easiest way to do this. char(32) doesn't seem to be working...
3
by: RicercatoreSbadato | last post by:
I'd like to print a TimeSpan variable in this way: 00:00:00 --hh:mm:ss (whitout the milliseconds) how can I do it?
3
by: John Sitka | last post by:
32.0 transformed to 000000320000000000 I guess the above would be equivalent to an numeric(18,10) datatype the first 8 digits represent the whole part of the double the last 10 represent the...
9
by: zion | last post by:
Hello, In my program I get data from table with 2 fields and enter it like in example into string array. How can I add the right spaces to the string? I use the function...
2
by: Jameson | last post by:
Hi, Dumb question for you: Is there a quick and easy way to ensure a string has a minimum width using format specifier? Should I just write if myString.Length < 8 then myString.PadLeft (...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.