.NET Format a string with fixed spaces
- by treant
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.