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

How to right justify number in String.Format ?

Hi All,

I am using

for(i = . . . . .)
sw.WriteLine(string.Format("{0} {1}", num1, num2));

and I am getting

12 123
1234 122
12435 15556

What I want is
12 123
1234 122
12435 15556
i.e. each number justified to the right hand side of its column

I tried using {0:#######}
but I am very new to this having just moved over from
C/C++

Any Ideas?

Kevin R
Nov 17 '05 #1
1 18301
I got it, it's {0,6} to right justify and {0,-6} to left justify
where 6 is the ammount of space the number is to take up

On Sun, 03 Jul 2005 14:01:58 +0100, Kevin R <me@privacy.net> wrote:
Hi All,

I am using

for(i = . . . . .)
sw.WriteLine(string.Format("{0} {1}", num1, num2));

and I am getting

12 123
1234 122
12435 15556

What I want is
12 123
1234 122
12435 15556
i.e. each number justified to the right hand side of its column

I tried using {0:#######}
but I am very new to this having just moved over from
C/C++

Any Ideas?

Kevin R


Nov 17 '05 #2

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

Similar topics

6
by: Leonard | last post by:
How do I right justify input data in a textbox? I have some textboxes that are used to input numbers, and I would like to right justify them.
2
by: jwatts | last post by:
Hello group, I am feeling pretty good about this program. I am just learning and am trying to get the basics down. I would like to ask if someone could tell me how to right justify the BALANCE...
4
by: Sam | last post by:
Hi everyone I have a question regarding string format. If I want to write a set of numeric values from arrays to a text file with the "right alignment" format as below, can it be done?...
2
by: Hans Kesting | last post by:
Hi, Can I right-align a number with leading *spaces*? F.i. I have the value 2 and I want to display it as " 2". int num = 2; string s = num.ToString("00"); // gives "02", but I don't want the...
0
by: Jean-François Michaud | last post by:
Hello people, I'm having a hard time figuring out how to align my page numbe properly to the right margin in the Table of content I'm generating. I'm using FOP and there are some known issues...
3
by: Leonardo da Vinci | last post by:
Greetings gentlemen and ladies, I have a question: in Tkinter, how to align a Listbox entry (i.e. a line of text) to the right? Google did not show up the answer to my request. Thanks very much....
3
by: mehdi | last post by:
I have a field that is a memo and I have a report displaying the text in that memo. What I need to know is how to "justify" the text right to left. The reason is in arabic and persian...
2
by: eighthman11 | last post by:
Hello everyone, I'm using Access 2000 and SQL 8.0 This maybe easy but I can't figure it out. I have a linked access table to a SQL server table. I use this table on a Grid on an Access form. ...
1
by: John A Grandy | last post by:
How to string format an integer to be right-justified within a field width of a specified number of characters ? in the following example , 'x' denotes space character xxxx0 xxxx1 .......
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.