+ 1
Why is throwing an exception ?
I'm trying to code a solution for project euler(1001st prime) but it's keep throwing a "outside the bounds of an array" exception at me.How can I fix it. https://code.sololearn.com/c9grd03e04Ui/?ref=app
4 Answers
+ 2
There is only 1 element in result[], so IndexOutOfRangeException is thrown.
+ 1
Console.WriteLine(result[10]);
This is causing your error. The array does not have 11 elements when you try to access it.
+ 1
How can i fix it
0
How does it have only one element