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. How to Format a string in c#

How to Format a string in c#

Scheduled Pinned Locked Moved C#
helpquestioncsharptutorial
9 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.
  • A Offline
    A Offline
    Arunkumar Koloth
    wrote on last edited by
    #1

    hai everyone , My problem is i have a employee code like EMPLOYEE i would like to change this to EMPLOYEE000001,EMPLOYEE000002 this format. How can i do this? with c# please help me :(( Arunkumar

    Arunkumar

    A OriginalGriffO 2 Replies Last reply
    0
    • A Arunkumar Koloth

      hai everyone , My problem is i have a employee code like EMPLOYEE i would like to change this to EMPLOYEE000001,EMPLOYEE000002 this format. How can i do this? with c# please help me :(( Arunkumar

      Arunkumar

      A Offline
      A Offline
      Andre Kraak
      wrote on last edited by
      #2

      You can use the Format[^] method like:

      uint EmployeeNumber = 1;

      String.Format( "EMPLOYEE{8:D}", EmployeeNumber );

      Remember you will be limited to 999999 employees.

      0100000101101110011001000111001011101001

      P 1 Reply Last reply
      0
      • A Arunkumar Koloth

        hai everyone , My problem is i have a employee code like EMPLOYEE i would like to change this to EMPLOYEE000001,EMPLOYEE000002 this format. How can i do this? with c# please help me :(( Arunkumar

        Arunkumar

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Where is the employee code stored? How do you determine which EMPLOYEE should be EMPLOYEE00001 and which EMPLOYEE00075? We need more information before we can give you a meaningful answer.

        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        A 1 Reply Last reply
        0
        • A Andre Kraak

          You can use the Format[^] method like:

          uint EmployeeNumber = 1;

          String.Format( "EMPLOYEE{8:D}", EmployeeNumber );

          Remember you will be limited to 999999 employees.

          0100000101101110011001000111001011101001

          P Offline
          P Offline
          ProEnggSoft
          wrote on last edited by
          #4

          It is

          string.Format("EMPLOYEE{0:D6}",EmployeeNumber);

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Where is the employee code stored? How do you determine which EMPLOYEE should be EMPLOYEE00001 and which EMPLOYEE00075? We need more information before we can give you a meaningful answer.

            Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

            A Offline
            A Offline
            Arunkumar Koloth
            wrote on last edited by
            #5

            André Kraak,ProEnggSoft Thank you for your answer and it's works! OriginalGriff, the employee code is stored in the database and it just a field for naming(like a roll no) a employee. i have a id filed for managing employees. when admin add a employee program fetch last inserted employee code. i writed a program for increasing the count. Thanks,

            Arunkumar.t

            M 1 Reply Last reply
            0
            • A Arunkumar Koloth

              André Kraak,ProEnggSoft Thank you for your answer and it's works! OriginalGriff, the employee code is stored in the database and it just a field for naming(like a roll no) a employee. i have a id filed for managing employees. when admin add a employee program fetch last inserted employee code. i writed a program for increasing the count. Thanks,

              Arunkumar.t

              M Offline
              M Offline
              Marcus_2
              wrote on last edited by
              #6

              Arunkumar.Koloth wrote:

              OriginalGriff, the employee code is stored in the database and it just a field for naming(like a roll no) a employee. i have a id filed for managing employees.
               
              when admin add a employee program fetch last inserted employee code. i writed a program for increasing the count.

              If you're using SQL Server why are you not using the identity column instead? http://msdn.microsoft.com/en-us/library/aa933196(v=sql.80).aspx[^] If you're not using SQL server there's probably some similar function in your database.

              A 2 Replies Last reply
              0
              • M Marcus_2

                Arunkumar.Koloth wrote:

                OriginalGriff, the employee code is stored in the database and it just a field for naming(like a roll no) a employee. i have a id filed for managing employees.
                 
                when admin add a employee program fetch last inserted employee code. i writed a program for increasing the count.

                If you're using SQL Server why are you not using the identity column instead? http://msdn.microsoft.com/en-us/library/aa933196(v=sql.80).aspx[^] If you're not using SQL server there's probably some similar function in your database.

                A Offline
                A Offline
                Arunkumar Koloth
                wrote on last edited by
                #7

                Marcus_2, My project is in MySQL server so i thing it is required.. suggest me if you have any other great idea. :-O Thank you Arunkumar

                M 1 Reply Last reply
                0
                • A Arunkumar Koloth

                  Marcus_2, My project is in MySQL server so i thing it is required.. suggest me if you have any other great idea. :-O Thank you Arunkumar

                  M Offline
                  M Offline
                  Marcus_2
                  wrote on last edited by
                  #8

                  Hi I've no idea about MyQL, but perhaps this might be helpful or at lest something to read and remember the functionality for future use: http://bytes.com/topic/mysql/answers/652076-how-create-identity-column-mysql It depends on how you do it, I just read this

                  Arunkumar.Koloth wrote:

                  i writed a program for increasing the count.

                  and tried to give an idea about using a feature built into a lot of databases. ;)

                  1 Reply Last reply
                  0
                  • M Marcus_2

                    Arunkumar.Koloth wrote:

                    OriginalGriff, the employee code is stored in the database and it just a field for naming(like a roll no) a employee. i have a id filed for managing employees.
                     
                    when admin add a employee program fetch last inserted employee code. i writed a program for increasing the count.

                    If you're using SQL Server why are you not using the identity column instead? http://msdn.microsoft.com/en-us/library/aa933196(v=sql.80).aspx[^] If you're not using SQL server there's probably some similar function in your database.

                    A Offline
                    A Offline
                    Arunkumar Koloth
                    wrote on last edited by
                    #9

                    Thanks For the link Marcus_2

                    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