Split string after each n number of lines in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mudassir
    New Member
    • May 2012
    • 85

    Split string after each n number of lines in C#

    Dear all,
    i want to split string after each 15 lines, suppose i have a string which contains multiple lines, i want to split that string after each 15 lines..

    any help will be greatly appreciated
  • pod
    Contributor
    • Sep 2007
    • 298

    #2
    Pseudo code... up to you to make it work in C#


    P:oD

    Code:
    splitString(myOriginalString) function{  
      myNewString = String.Empty
      myNewStringArray() 
      lineArray()= myOriginalString.Split(linebreak)
      For arrayItem = 0 To lineArrayItemCount (probably - 1)
        If arrayItem Mod 15 = 0 Then
          myNewString = myNewString & "~" & lineArray(itm)
        Else
          myNewString = myNewString & lineArray(itm)
        End 
      Next arrayItem
      myNewStringArray = myNewString.Split("~")
    }

    Comment

    • Mudassir
      New Member
      • May 2012
      • 85

      #3
      dear pod !
      thanx, it worked perfectly..

      Comment

      Working...