I have the following array:
public string reArrange(string s)
{
char[] array = s.ToCharArray();
int length = array.Length;
char[] arranged = new char[length];
for (int i = 0; i < length; i++)
{
int newposition = length - i;
arranged[newposition] = array[i];
}
return new string(arranged);
}
But the above method raises the following error:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
So what might be wrong?