- 1

Arregle el problema de que no me daba ningun resultado, pero porque sige saltandome ese error?

https://code.sololearn.com/cxbyUxvUvcP7/?ref=app

16th Nov 2020, 10:44 PM
LenadESP
LenadESP - avatar
2 odpowiedzi
+ 1
The loop is set up to execute forever, despite the attempt to add a conditional break statement.    while (Num.Count() > num2.Count() - 3) is the same as    while (3 > 0) The condition is always true so the loop never exits. Inside the loop, the condition to break has a similar problem.    if (num2.Count() - 2 >= Num.Count()) is the same as    if (1 >= 3) It is always false, so the break statement never executes. Therefore, x keeps incrementing and causes an "out of bounds" error. To fix this, test the value of x in the conditionals. I think this is what you need: while (x < Num.Count() && x < num2.Count()) The above line ensures that x will never get out of bounds of either array, even if they are different sizes. Then you may remove the conditional break statement, too.
17th Nov 2020, 1:52 AM
Brian
Brian - avatar
+ 2
Thank you bery much! I am new in C# and is a little difficult when you start. But i understand where is the error.
17th Nov 2020, 4:18 PM
LenadESP
LenadESP - avatar