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. Split Particular Digit using C#

Split Particular Digit using C#

Scheduled Pinned Locked Moved C#
csharphelptutorial
5 Posts 4 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.
  • N Offline
    N Offline
    nick703
    wrote on last edited by
    #1

    hello Friend i have to know how to split below string in particular part. i have find this type of string in bar-code scanner as a input

    I have a input
    Hide Copy Code
    0.1042.5140.7043.037.000.005.063.613.761.70.062
    and i want output
    0.104
    2.51
    40.70
    43.0
    37.00
    0.00
    5.0
    63.6
    13.7
    61.7
    0.06

    please help me to solve this.

    P P L 3 Replies Last reply
    0
    • N nick703

      hello Friend i have to know how to split below string in particular part. i have find this type of string in bar-code scanner as a input

      I have a input
      Hide Copy Code
      0.1042.5140.7043.037.000.005.063.613.761.70.062
      and i want output
      0.104
      2.51
      40.70
      43.0
      37.00
      0.00
      5.0
      63.6
      13.7
      61.7
      0.06

      please help me to solve this.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      So you're looking at positional indexing. In other words, get the string from position 0 to 4 then 5 to 8 and so on. The string class has many features that could make this life easier for you but, if I were you, I would look at the Substring[^] command.

      This space for rent

      1 Reply Last reply
      0
      • N nick703

        hello Friend i have to know how to split below string in particular part. i have find this type of string in bar-code scanner as a input

        I have a input
        Hide Copy Code
        0.1042.5140.7043.037.000.005.063.613.761.70.062
        and i want output
        0.104
        2.51
        40.70
        43.0
        37.00
        0.00
        5.0
        63.6
        13.7
        61.7
        0.06

        please help me to solve this.

        P Offline
        P Offline
        Peter Leow
        wrote on last edited by
        #3

        What is the basis or pattern for the split? You example appears random.

        Peter Leow http://www.peterleowblog.com/ https://www.amazon.com/author/peterleow

        1 Reply Last reply
        0
        • N nick703

          hello Friend i have to know how to split below string in particular part. i have find this type of string in bar-code scanner as a input

          I have a input
          Hide Copy Code
          0.1042.5140.7043.037.000.005.063.613.761.70.062
          and i want output
          0.104
          2.51
          40.70
          43.0
          37.00
          0.00
          5.0
          63.6
          13.7
          61.7
          0.06

          please help me to solve this.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          string s = "0.1042.5140.7043.037.000.005.063.613.761.70.062";
          List widths = new List() { 5, 4, 5, 4, 5, 4, 3, 4, 4, 4, 4 };
          int index = 0;

          widths.ForEach( w => { Console.WriteLine( s.Substring( index, w ) ); index += w; } );

          N 1 Reply Last reply
          0
          • L Lost User

            string s = "0.1042.5140.7043.037.000.005.063.613.761.70.062";
            List widths = new List() { 5, 4, 5, 4, 5, 4, 3, 4, 4, 4, 4 };
            int index = 0;

            widths.ForEach( w => { Console.WriteLine( s.Substring( index, w ) ); index += w; } );

            N Offline
            N Offline
            nick703
            wrote on last edited by
            #5

            thanks a lot substring work for me.

            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