String.Format with a variable field width
- From: MC <nospam@xxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 03:12:26 GMT
In C, printf allows us to specify a runtime (non-constant) field width
of a formatted value by using the * character. Is there something
like that for System.String.Format? In C#, I find myself having to
use concatenation, which is awkward to write and to read:
s.Format("{0," + fieldWidth.ToString() + "}", val);
Preferably, I'd like to nest two placeholders, like this:
s.Format("{0,{1}}", val, fieldWidth);
but it doesn't like that (Framework 2.0).
Is currently available somehow? I didn't see it in MSDN. If not, was
there never any noise about the lack of it in Framework 1.x?? And are
there any plans to add it in the near future?
Thanks,
Craig
.
- Follow-Ups:
- Re: String.Format with a variable field width
- From: Buddy Home
- Re: String.Format with a variable field width
- Prev by Date: Re: ServiceTimer won't fire
- Next by Date: Re: .NET 2.0 performance bug in ArrayList.Sort
- Previous by thread: .NET 2.0 performance bug in ArrayList.Sort
- Next by thread: Re: String.Format with a variable field width
- Index(es):
Relevant Pages
|