How to right justify number in String.Format ?

  • Thread starter Thread starter Kevin R
  • Start date Start date
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
 
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
 
Back
Top