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

Re: formatting by Jon

Jon
Wed Dec 03 05:24:00 CST 2003

barak <anonymous@discussions.microsoft.com> wrote:
> 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>

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

Re: formatting by anonymous

anonymous
Wed Dec 03 06:56:08 CST 2003

thanks
>-----Original Message-----
>barak <anonymous@discussions.microsoft.com> wrote:
>> 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>
>
>--
>Jon Skeet - <skeet@pobox.com>
>http://www.pobox.com/~skeet
>If replying to the group, please do not mail me too
>.
>