formatting

  • Thread starter Thread starter barak
  • Start date Start date
B

barak

please explain me the following formatting:

Console.WriteLine("{0,-12:N0} {1,-20:g}
{2}",size,creationTime, name).

what is the meaning of the -12,-20 prefix?

Thanks
Barak
 
barak said:
please explain me the following formatting:

Console.WriteLine("{0,-12:N0} {1,-20:g}
{2}",size,creationTime, name).

what is the meaning of the -12,-20 prefix?

It's the "alignment" component of the format specifier. From MSDN
(under "Composite Formatting"):

<quote>
The optional alignment component is a signed integer indicating the
preferred formatted field width. If the value of alignment is less than
the length of the formatted string, alignment is ignored and the length
of the formatted string is used as the field width. The formatted data
in the field is right-aligned if alignment is positive, and left-
aligned if alignment is negative. If padding is necessary, white space
is used. The comma is required if alignment is specified.
</quote>
 
thanks
-----Original Message-----


It's the "alignment" component of the format specifier. From MSDN
(under "Composite Formatting"):

<quote>
The optional alignment component is a signed integer indicating the
preferred formatted field width. If the value of alignment is less than
the length of the formatted string, alignment is ignored and the length
of the formatted string is used as the field width. The formatted data
in the field is right-aligned if alignment is positive, and left-
aligned if alignment is negative. If padding is necessary, white space
is used. The comma is required if alignment is specified.
</quote>

--
Jon Skeet - <[email protected]>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.
 

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

Back
Top