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. Show the id in 5 Digits

Show the id in 5 Digits

Scheduled Pinned Locked Moved C#
databasedata-structures
6 Posts 5 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.
  • G Offline
    G Offline
    GauravGupta212
    wrote on last edited by
    #1

    Hiii everyone Actually i am geting memberid from database as 1,2,123,124 but i want to amend the id as 00001,00002,00123 etc. Anyone can suggest me how i can get it. using array or any collection. Thanks in advance Gaurav Gupta

    A X realJSOPR L 4 Replies Last reply
    0
    • G GauravGupta212

      Hiii everyone Actually i am geting memberid from database as 1,2,123,124 but i want to amend the id as 00001,00002,00123 etc. Anyone can suggest me how i can get it. using array or any collection. Thanks in advance Gaurav Gupta

      A Offline
      A Offline
      ali_reza_zareian
      wrote on last edited by
      #2

      you can use split method then made a new id.

      string _temp="1,12,123";
      string[] arr=_temp.split(new char[]{','});

      G 1 Reply Last reply
      0
      • G GauravGupta212

        Hiii everyone Actually i am geting memberid from database as 1,2,123,124 but i want to amend the id as 00001,00002,00123 etc. Anyone can suggest me how i can get it. using array or any collection. Thanks in advance Gaurav Gupta

        X Offline
        X Offline
        Xmen Real
        wrote on last edited by
        #3

        string formatted = 123.ToString("00000");

        TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

        ----------------------------------------------- 128 bit encrypted signature, crack if you can

        1 Reply Last reply
        0
        • A ali_reza_zareian

          you can use split method then made a new id.

          string _temp="1,12,123";
          string[] arr=_temp.split(new char[]{','});

          G Offline
          G Offline
          GauravGupta212
          wrote on last edited by
          #4

          Hii Ali Thnaks for the response but actually i have id like 1.Now i want to make the id 0001 dynamically using for loop and array. e.g. if i have id 123 first read 3 then submit 3 in array which have 00000 now string have 12 read 2 and then submit in array noe 00023 i have now anly 1 remain get 1 and submit in array now id becomes 00123.Like that Thanks Gaurav

          1 Reply Last reply
          0
          • G GauravGupta212

            Hiii everyone Actually i am geting memberid from database as 1,2,123,124 but i want to amend the id as 00001,00002,00123 etc. Anyone can suggest me how i can get it. using array or any collection. Thanks in advance Gaurav Gupta

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            int id = 1;
            string longID = string.Format("{0:00000}", id);

            this will result in "00001";

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            1 Reply Last reply
            0
            • G GauravGupta212

              Hiii everyone Actually i am geting memberid from database as 1,2,123,124 but i want to amend the id as 00001,00002,00123 etc. Anyone can suggest me how i can get it. using array or any collection. Thanks in advance Gaurav Gupta

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Hi, When the data are integers, you store them as integers in the database, which will hold their value, and isn't interested in any formatting. When you show such numbers, make sure to apply the format you want. One way of getting that is:

              int a=123;
              Console.WriteLine("a="+a.ToString("D5"));

              :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


              I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


              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