using System;
using System.Linq;
using System.Collections.Generic;
public static class Program
{
public static IEnumerable<string> Split(this string str, int length) {
if (String.IsNullOrEmpty(str) || length < 1) {
throw new ArgumentException();
}
return Enumerable.Range(0, str.Length / length)
.Select(i => str.Substring(i * length, length));
}
public static void Main(string[] args)
{
string str = "java c++ c python c#";
int length = 5;
IEnumerable<string> chunks = str.Split(length);
Console.WriteLine(String.Join(Environment.NewLine, chunks));
}
}
/*
run:
java
c++ c
pyth
on c#
*/