How to right justify number in String.Format ?

K

Kevin R

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
 
K

Kevin R

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top