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. format problem

format problem

Scheduled Pinned Locked Moved C#
help
3 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.
  • D Offline
    D Offline
    darkcalin
    wrote on last edited by
    #1

    Hi, i have one number and i want to transform in one string but with one fixed format: EX: if i have int x=10; int y=999; my string must be string sForX="0010"; string sForY="0999"; (i want to do that without to format the string manual (with for, while or.....) )

    M 1 Reply Last reply
    0
    • D darkcalin

      Hi, i have one number and i want to transform in one string but with one fixed format: EX: if i have int x=10; int y=999; my string must be string sForX="0010"; string sForY="0999"; (i want to do that without to format the string manual (with for, while or.....) )

      M Offline
      M Offline
      mabo42
      wrote on last edited by
      #2

      You can use String.Format:

      int x=10;
      int y=999;

      string sForX=String.Format("{0:0000}", x);
      string sForY=String.Format("{0:0000}", y);

      D 1 Reply Last reply
      0
      • M mabo42

        You can use String.Format:

        int x=10;
        int y=999;

        string sForX=String.Format("{0:0000}", x);
        string sForY=String.Format("{0:0000}", y);

        D Offline
        D Offline
        darkcalin
        wrote on last edited by
        #3

        This is what i want!!!! Tks

        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