I'm using StringBuilder
to replace each character in a string by using an int that gets converted to a char. For some reason, the string builder throws an "Out of index error" even if the index is inside of the range.
I want to use I as the index but I changed it to array.Length
just to make sure the index was in range.
string input = Console.ReadLine();
char[] array = input.ToCharArray();
int totalOffsetToRemove = array.Length + 44;
StringBuilder sb = new StringBuilder(input);
string result;
for (int i = array.Length; i > 0; i--)
{
char c = Convert.ToChar(totalOffsetToRemove);
sb[array.Length] = c;
result = sb.ToString();
Console.WriteLine(result);
totalOffsetToRemove -= 2;
}