473,395 Members | 1,936 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,395 software developers and data experts.

Spacer characters in format strings

I am trying to make a format string for use in methods such as
String.Format. I want the formatted string to be a fixed length with any
empty spaces to be filled with a specified character. For example, I would
want the following statement:

String.Format("{0,5}","abc")

To return:

00abc

However, when this type of format string is used the empty spaces are filled
with spaces. I am aware that this is what is expected, but is there a way to
specify a character to use for filling the empty spaces? Any help would be
appreciated. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jun 27 '08 #1
1 1035
On May 20, 8:28*pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I am trying to make a format string for use in methods such as
String.Format. I want the formatted string to be a fixed length with any
empty spaces to be filled with a specified character. For example, I would
want the following statement:

String.Format("{0,5}","abc")

To return:

00abc

However, when this type of format string is used the empty spaces are filled
with spaces. I am aware that this is what is expected, but is there a way to
specify a character to use for filling the empty spaces? Any help would be
appreciated. Thanks.
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
Use String.PadLeft Method
http://msdn.microsoft.com/en-us/libr...g.padleft.aspx
Jun 27 '08 #2

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

Similar topics

2
by: Holysmoke | last post by:
Hi, I want to split a big string by nymber of characters. for eg., if total length of the string is 80 and I want to split by each 10 characters and get 8 lines of output. I written a...
5
by: Martijn | last post by:
Hi, I think I can best ask my question by example. I may be overlooking something, but this is like what I have: #define ID1 'i' #define ID2 'd' #define ID3 'n' This is what I...
9
by: Bert Szoghy | last post by:
Hello, I am struggling with an extended stored procedure DLL coded in C. The SQL Server database contains French accented characters. The DLL drops them as it passes on the data to managed code....
4
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
2
by: neuneudr | last post by:
Hi everybody, I'm scratching my head with a CSS problem. I want to have the following (the two pics have these size for a good reason, the whole point of the page is basically to show these...
2
by: Jeremie Le Hen | last post by:
(Mail resent with the proper subject. Hi list, (Please Cc: me when replying, as I'm not subscribed to this list.) I'm working with Unicode strings to handle accented characters but I'm...
6
by: geegeegeegee | last post by:
Hi All, I have come across a difficult problem to do with extracting UniCode characters from RTF strings. A detailed description of my problem is below, if anyone could help, it would be much...
4
by: Mandragon03 | last post by:
Anyone know if the standard sprintf supports utf8 characters that extend beyond the normal ascii characters? Thanks!
1
by: Nathan Sokalski | last post by:
I am trying to make a format string for use in methods such as String.Format. I want the formatted string to be a fixed length with any empty spaces to be filled with a specified character. For...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.