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. str(number,width,presicion) function

str(number,width,presicion) function

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 3 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.
  • A Offline
    A Offline
    AndrusM
    wrote on last edited by
    #1

    How to implement string Str( float number, ushort width, ushort presicion) should return string whose size if width characters, left padded by spaces and having presicion characters after decimal point using current culture decimal separator?

    Andrus

    C V 2 Replies Last reply
    0
    • A AndrusM

      How to implement string Str( float number, ushort width, ushort presicion) should return string whose size if width characters, left padded by spaces and having presicion characters after decimal point using current culture decimal separator?

      Andrus

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The string.Format method will do this for you.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      A 1 Reply Last reply
      0
      • C Christian Graus

        The string.Format method will do this for you.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        A Offline
        A Offline
        AndrusM
        wrote on last edited by
        #3

        Thank you. Do you have any sample how to pass width and presicion variables to Format() and return padded string ?

        Andrus

        1 Reply Last reply
        0
        • A AndrusM

          How to implement string Str( float number, ushort width, ushort presicion) should return string whose size if width characters, left padded by spaces and having presicion characters after decimal point using current culture decimal separator?

          Andrus

          V Offline
          V Offline
          Vega02
          wrote on last edited by
          #4

          This[^] section of MSDN doc covers string formatting in detail. There are some examples for you to examine. You should be able to find what you need in there. Good luck! :)

          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