-3

Hi want to get a string cutted by a number like "abcdefgh" (split by 4) string[] = "ab, cd, ef, gh".

1 Answers1

0

Duplicate: Splitting a string into chunks of a certain size

    static IEnumerable<string> Split(string str, int chunkSize)
{
    return Enumerable.Range(0, str.Length / chunkSize)
        .Select(i => str.Substring(i * chunkSize, chunkSize));
}

This answer was my favorite.

JBatstone
  • 167
  • 7