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
Here is my solution, without overdoing it.
private static string AppendAtPosition(string baseString, int position, string character)
{
var sb = new StringBuilder(baseString);
for (int i = position; i < sb.Length; i += (position + character.Length))
sb.Insert(i, character);
return sb.ToString();
}
Console.WriteLine(AppendAtPosition("abcdefghijklmnopqrstuvwxyz", 5, "-"));