Created
May 10, 2017 17:09
-
-
Save arman-hpp/a1e8aa1090a86fe6dcc0559d25223534 to your computer and use it in GitHub Desktop.
Split By Iteration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<string> Split(string str, int iterateCount) | |
{ | |
var words = new List<string>(); | |
for (int i = 0; i < str.Length; i += iterateCount) | |
if (str.Length - i >= iterateCount) | |
words.Add(str.Substring(i, iterateCount)); | |
else | |
words.Add(str.Substring(i, str.Length - i)); | |
return words; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment