- Home /
How to create a table, array of array?
I want to create a table of records, such as:
id name score kills deaths
1 Player1 10 1 1
2 Player2 20 2 4
3 Player3 50 5 3
came to this method:
class Players {
int id;
string name;
int score;
int kills;
int deaths;
}
But there was a problem sorted. I can use the system.array.sort, but only on a one-dimensional array.
Just heard about ICompare to sort multidimensional array, but do not know how and where to use it. Tell me please.
Answer by YoungDeveloper · Oct 20, 2013 at 01:09 PM
Easiest way and probably most optimized would be rendering it with simple for loop. For this all what you need to know is, who is in what place. You could save each row in string, which all together is an array.
for(int i <0; i < amountOfPlayers; i++){
someStringArray[0] = name + score + kills + deaths;
}
Then just render the string array in on gui.
But as for finding a way to store information about each player, stats, etc.. It really depends on your game type and your needs, there is no default way of doing this.
Define "sorted"
If each string element is for one player, you can sort it pretty easy.
In program$$anonymous$$g there is no term "can not be".
Your answer
Follow this Question
Related Questions
I'm desperate with my scoreboard! (Array, Javascript) 1 Answer
Trying to sort an array. What's wrong here? 1 Answer
Problems with Arrays 2 Answers
IndexOutofRangeException 1 Answer
XML File, or Array? 1 Answer