.NET Format a string with fixed spaces
Posted
by treant
on Stack Overflow
See other posts from Stack Overflow
or by treant
Published on 2009-03-13T18:29:13Z
Indexed on
2010/03/11
18:49 UTC
Read the original article
Hit count: 172
.NET
|string-manipulation
Does the .NET String.Format method allow placement of a string at a fixed position within a fixed length string.
" String Goes Here" " String Goes Here " "String Goes Here "
How is this done using .NET?
Edit - I have tried Format/PadLeft/PadRight to death. They do not work. I don't know why. I ended up writing my own function to do this.
Edit - I made a mistake and used a colon instead of a comma in the format specifier. Should be "{0,20}".
Thanks for all of the excellent and correct answers.
© Stack Overflow or respective owner