- Home /
Add arrays to a big array?
I was thinking that instead of having lots of arrays I could have one big array with all my arrays in them. For example, I have something like:
public static string[][][] answers;
public static string[][] cartoon;
public static string[] cartoonLvlOne;
Is there anyway to make one array part of another? This is for a quiz game so could cartoon be in the answers array and then in the cartoon array there be an array for each set of answers for each level. I would have all my different categories in the answers array and then in each category array there would be an array with a set of answers for each specific level. Is there anyway to do that?
Answer by rob5300 · Jan 15, 2015 at 09:32 PM
Hmm, maybe a custom class would be the best, and having arrays in them? I'm not sure it is possible to add an array to an array. Maybe something like a List or Dictionary would be useful, as they can hold themselves.
For example a Dictionary has a Key and holds a value. Soo you could have the key as the level name, and they value as another Dictionary that holds the answer id and answer. Experiment!
//Example Code, may NOT WORK! (Should be similar to this)
using System.Collections.Generic
public Dictionary<string,Dictionary<string,string>> Answers = new Dictionary<string,Dictionary<string,string>>();
//Accessible like so maybe?:
string answer = Answers<"Cartoon">.<"answer1">;
http://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx (List)
http://msdn.microsoft.com/en-us/library/xfhwa508%28v=vs.110%29.aspx (Dictionary)
Answer by Ericool · Jan 15, 2015 at 09:34 PM
Yes as long as its all of same type,but I can suggest you to use maybe a dictionnary.
Your answer
Follow this Question
Related Questions
Question about arrays on android. 0 Answers
GUI Joystick 1 Answer
How to save an array of string in Android? 1 Answer
Android car controls c# 0 Answers