Cobra,
I would use a stringbuilder for this, it might make it a little faster
(and if you are doing this in a loop, you could clear the contents of the
builder with each iteration, without reducing the buffer):
// The builder.
StringBuilder builder = new StringBuilder();
// In the loop.
// This will only set the length of the string to 0, it won't get rid of the
// buffer already allocated.
builder.Length = 0;
// Append the 12 spaces and the decimal.
builder.AppendFormat(" {0:N2}", d);
// Get the string.
builder.ToString();
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
<Co**********@al.com> wrote in message
news:Qf****************@newsfe2-gui.ntli.net...
Hi all,
Is there one operation to do the following more efficiently,need to
format upto 500 in one go
decimal d;
d.ToString("N2").PadLeft(12);
thank you.