I know I can append to a string but I want to be able to add a specific character after every 5 characters within the string
from this string alpha = abcdefghijklmno
You may define this extension method:
public static class StringExtenstions
{
public static string InsertCharAtDividedPosition(this string str, int count, string character)
{
var i = 0;
while (++i * count + (i - 1) < str.Length)
{
str = str.Insert((i * count + (i - 1)), character);
}
return str;
}
}
And use it like:
var str = "abcdefghijklmnopqrstuvwxyz";
str = str.InsertCharAtDividedPosition(5, "-");