By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Split string after each n number of lines in C#

P: 85
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
Sep 23 '14 #1

✓ answered by pod

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


P:oD

Expand|Select|Wrap|Line Numbers
  1. splitString(myOriginalString) function{  
  2.   myNewString = String.Empty
  3.   myNewStringArray() 
  4.   lineArray()= myOriginalString.Split(linebreak)
  5.   For arrayItem = 0 To lineArrayItemCount (probably - 1)
  6.     If arrayItem Mod 15 = 0 Then
  7.       myNewString = myNewString & "~" & lineArray(itm)
  8.     Else
  9.       myNewString = myNewString & lineArray(itm)
  10.     End 
  11.   Next arrayItem
  12.   myNewStringArray = myNewString.Split("~")
  13. }

Share this Question
Share on Google+
2 Replies


pod
100+
P: 298
pod
Pseudo code... up to you to make it work in C#


P:oD

Expand|Select|Wrap|Line Numbers
  1. splitString(myOriginalString) function{  
  2.   myNewString = String.Empty
  3.   myNewStringArray() 
  4.   lineArray()= myOriginalString.Split(linebreak)
  5.   For arrayItem = 0 To lineArrayItemCount (probably - 1)
  6.     If arrayItem Mod 15 = 0 Then
  7.       myNewString = myNewString & "~" & lineArray(itm)
  8.     Else
  9.       myNewString = myNewString & lineArray(itm)
  10.     End 
  11.   Next arrayItem
  12.   myNewStringArray = myNewString.Split("~")
  13. }
Sep 23 '14 #2

P: 85
dear pod !
thanx, it worked perfectly..
Sep 24 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.