C
C#ā€¢2y ago
cipro

ā” reverse of RemoveAt[index]

hi, so my problem is that im itterating through a list of 10 questions, and each time the user has completed a question from the list, i use thed the RemoveAt(index) function so that the same question isnt repeated. the problem is that at the end of the program, the user is asked if they want to repeat the exercise and if they click yes lets say, then the questions they have already completed will still be removed, as in the program will crash once it itterates past the first and final index. i forgot to mention that the user will only be asked 5 questions so that the program doesnt crash by itterating further than the final and initial index. so how can i counter this problem so that when the user is done and they press yes to retry, the indexes are reset?
3 Replies
phaseshift
phaseshiftā€¢2y ago
Just don't use indexes bigger than the list If you want to put the seen questions back in the list, then just do that? šŸ¤·ā€ā™‚ļø
cipro
ciproOPā€¢2y ago
sorry wut ahaha it itterates through the list but not using a for loop yeh thats what im asking, how i used the list<t>.clear() function and it somehow seemse to be working lol
Accord
Accordā€¢2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server