Variable with number, using int instead

I was wondering if it possible to do this.
To use an int in an variable name.


float number1 = 10f;
float number2 = 10f;

int chooseNumber = 1;

number+"choosenumber.ToString" = 15f;

So i’m trying to acces the float number1 but instead of typing 1 im trying to use the int to say its number1

Use a float array instead of 2 float.

I think what your asking is, can you use the “1” from chooseNumber as a string and then add it to number1?

You can’t do what you did above because you’re adding a float (I think you meant number1 instead of number) to a string, and then giving it a float value.

If you wanted to add the two numbers together, you can do

float newNumber = number1+ chooseNumber;

If you wanted to see what the new number is you can use print()

print(number1 + chooseNumber);