Console.WriteLine("Enter the string you would want to compress using RLE format");
string UserInput = Console.ReadLine();
int repitions = 1;
for (int i = 0; i < UserInput.Length; i++)
{
if (UserInput[i] == UserInput[i + 1])
{
repitions++;
}
else
{
Console.WriteLine("{0}{1}", repitions, UserInput[i]);
repitions = 1;
}
}
In line 5, there is an error where it says
index was outside the bounds.
My aim is to use this compression and output the number of times the characters repeats and the type of character then move onto the next. Im not sure what is wrong here.
Im expecting a proper working RLE algorithm.