Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Formatting Console.WriteLine

Formatting Console.WriteLine

Scheduled Pinned Locked Moved C#
questioncss
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    budidharma
    wrote on last edited by
    #1

    Alright, I'm writing a bunch of integers to the screen of different lengths, followed by other numbers. Some are 3 digits long, some are five digits long, and the maximum is about 6 digits long. If the number is less than 6 digits long, I want it to write extra spaces after the number, to make it 6 total characters, before displaying more data. Etc. How do I do this? Thanks, As Always.

    C 1 Reply Last reply
    0
    • B budidharma

      Alright, I'm writing a bunch of integers to the screen of different lengths, followed by other numbers. Some are 3 digits long, some are five digits long, and the maximum is about 6 digits long. If the number is less than 6 digits long, I want it to write extra spaces after the number, to make it 6 total characters, before displaying more data. Etc. How do I do this? Thanks, As Always.

      C Offline
      C Offline
      Curtis Schlak
      wrote on last edited by
      #2

      You should take a look at the Composite Formatting article on MSDN. It shows you the ins and outs of the process. For your immediate satisfaction, though, try this: String.Format( "{0,-6} {1,-6} {2,-6}", 7, 3.14, 0.5 ); "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty -- modified at 19:58 Thursday 24th November, 2005

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups