I just working on my quiz game and its gonna be pretty large with hundrets of topics and questions, BUT as it has grown over 100+ questions split in 10 topics, it starts to crash on android when the array gets filled.
When i tested with 30 Questions / 3 Topics in the beginning everything was running smooth.
So i think this is maybe too big for a android phone :/, any ideas how to use them without crashing when reaching over 100 questions or what mobile friendly i could use instead of these 3 Arrays ?:
Quiz_text = new string[1, 25, 17, 6];
Quiz_answere_number = new int[1, 25, 17, 1];
Quiz_size_number = new int[1, 25, 17, 1];
the array means [Language, Topic, Questions, Answere]
It looks like you’re using 4D arrays there, which might be causing you issues. Without knowing how much data you’re actually using, though, I can’t tell. The arrays you define above should work, but new string[10,100,1000,10000] will almost certainly crash.
Also these “square arrays” may be instantiating lots of empty spaces, for instance if not all topics have the same number of questions, or not all questions need 6 answers. If this is the case, you’ll probably want to use arrays-of-arrays instead, defined like new string[10]. Then you have to create each individual sub array, BUT they can be different sizes, like Quiz_text[0] = new string[10], and Quiz_text[1] = new string[8].
But doing that will get you into indexing nightmares, so I’d pursue something more descriptive, like a data structure:
struct Question {
public string Language;
public string Topic;
public string Question;
public string[] Answers;
public int CorrectAnswerIndex;
//something for Quiz_size_number but idk what that is supposed to be?
}
//you can easily instantiate arrays of this size
Question[] AllQuestions = new Question[100000];