List, for loop and removal of items

Hey there, first time writing here, so bare with me if I’m doing something wrong.

So what I’m currently working on is a game for parties. Now, I made a Settings scene containing 3 checkboxes, Questions, Games and Dares, and you can toggle/untoggle them.

Then when the game initializes, I create a loop through all the questions and check their categories (Which are selected in the inspector for each question) and if the questions category matches one of the checkboxes (If you toggle/untoggle, they change a public bool which I can access for each category) then the question has to be removed.

It works fairly well, the checkboxes change the bools etc. but the removal of the ones that are unselected doesn’t work.

This is the loop:

	for(int i = 0; i < AllQuestions.Count; i++)
	{

		if (AllQuestions*.category == "Question" && !SettingsManager.Questions)*
  •   	{*
    

_ AllQuestions.Remove(AllQuestions*);_
_
}_
_ else if (AllQuestions.category == “Game” && !SettingsManager.Games)
{
AllQuestions.Remove(AllQuestions);
}
else if (AllQuestions.category == “Dare” && !SettingsManager.Dares)
{
AllQuestions.Remove(AllQuestions);
}
}*

is it possible that it might be that the table is a private static?_

@Persious I don’t know if this is your issue, but it could be that Array.Remove(string) isn’t an existing function.
Try:

AllQuestions.RemoveAt(i); //This function removes the i value from an array, i.e. RemoveAt(0) removes the first value in an array

@valkailcai I changed from Remove to RemoveAt(i), but it’s still doing something weird.

I uncheck all the categories (Which means the list should be empty), then I Debug.Log(AllQuestions.Count) before and after the loop and for some reason it debugs 42 before the loop which is alright, but after the loop is says 21, which makes no sense as it should show 0.