我有这个给我IndexOutOfRangeException的方法,你们能帮我理解为什么吗?
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();
}
方法必须这样写(无一例外)