I have this method that gives me IndexOutOfRangeException, can you guys help me to understand why?
public string FlipString(string inTxt)
{
StringBuilder outTxt = new StringBuilder();
for (int i = inTxt.Length; i > 0; i--)
{
char ch = inTxt[i];
outTxt.Append(ch);
}
Console.WriteLine(outTxt.ToString());
return outTxt.ToString();
}
The method has to be written like this (without the exception)