Nicely formatted text file

后端 未结 1 1654
忘了有多久
忘了有多久 2021-01-01 05:58

I’m writing to a text file and it looks like this...

19/05/2010 15:33:34   Verbose Main    in main method
19/05/2010 15:33:34   Information Does         


        
相关标签:
1条回答
  • 2021-01-01 06:06

    To align a string to the left use formatting pattern with comma (,) followed by a negative number of characters:

    LogFile.Write(string.Format("{0,-10} {1,-11} {2,-30} {3}", ...));
    

    For right alignment use a positive number.

    0 讨论(0)
提交回复
热议问题