- Home /
naming a variable with a number
This is probably a very silly question but I am trying to name a variable to put into an array. How would you make it so it is the variable name and then the number?
for(int i = 0; i < waypoints.Length; ++i){
//name the variable
waypoints[i - 1] = //name of variable;
}
Comment
But the whole point of arrays is not needing to do that. :((((
Correct, you never want to have a bunch of different variable names, under any circumstances. Ins$$anonymous$$d of var1, var2, etc., you use an array with var[0], var[1], etc.
Best Answer
Answer by Supercrusher9000 · Feb 21, 2014 at 01:47 AM
Wait, are you trying to change the variable value to a number, because I don't think it would be a wise decision to make the name itself a number.
no it would be like waypoint1 or waypoint2 with the number at the end being the value of i.