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. Web Development
  3. ASP.NET
  4. Class for looping every Character of string

Class for looping every Character of string

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
3 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.
  • C Offline
    C Offline
    chitra4sat
    wrote on last edited by
    #1

    Hi all, i am new to this ASp.net 2.0(C#) programming. I need a class which loops through every Character of a given String and basket them as two seperate string variable by the following. One basket will collect only input string start from a to g and the other collect h to z character. for eg: microsoft is the input string. in that first basket it will have "cf" and in the second basket it will have "mirosot". With Regards, Chitra

    A G 2 Replies Last reply
    0
    • C chitra4sat

      Hi all, i am new to this ASp.net 2.0(C#) programming. I need a class which loops through every Character of a given String and basket them as two seperate string variable by the following. One basket will collect only input string start from a to g and the other collect h to z character. for eg: microsoft is the input string. in that first basket it will have "cf" and in the second basket it will have "mirosot". With Regards, Chitra

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

      I would use myString.ToCharArray() to generate the array of characters. Create two StringBuilder objects. Then loop through the array using a compare function to determine which StringBuilder gets the character.

      1 Reply Last reply
      0
      • C chitra4sat

        Hi all, i am new to this ASp.net 2.0(C#) programming. I need a class which loops through every Character of a given String and basket them as two seperate string variable by the following. One basket will collect only input string start from a to g and the other collect h to z character. for eg: microsoft is the input string. in that first basket it will have "cf" and in the second basket it will have "mirosot". With Regards, Chitra

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        You can use a regular expression to match the characters. Call Regex.Replace with a delegate that will store away each matched character and replace it with an empty string. Something like: string second = string.Empty; string first = Regex.Replace(text, "[a-z]+", delegate(Match m){ second += m.Value; return string.Empty; } ); If the string might be large, a StringBuilder would be better for collecting the characters.

        --- single minded; short sighted; long gone;

        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