- 1
Arregle el problema de que no me daba ningun resultado, pero porque sige saltandome ese error?
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.
+ 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.