There is a function of the form:

string MyFunc(string input) { for (int i = 0; i < input.Lenght; i++) { //разнообразные вычисления, например такие: input = input.Replace("bla", "bla1"); //а здесь рекурсивный вызов: input = MyFunc(input); } } 

Inside, the output for the chapels line. That is, in the condition:

 if (input[i] == 'b') 

Actually the question is: For a for loop, is the i <input.Lenght entry evaluated once? It turns out that the input line is reduced, and (i <input.Lenght) remains const? And how to avoid it right away?

    1 answer 1

    Most likely, the problem is that you are trying to access the string by an index AFTER a recursive call. When the line is already shortened by a recursive call, and in the current call i <input.Length worked for the previous length of the line.

    • Yeah, it is. Thank. - Jakeroid
    • I fixed it, hmm, thanks. The mnu from the condition to the condition ran and did not go out of the cycle when necessary. - Jakeroid