I have to make reference more that a hundred variables in if statements, I could just type them all out, but is there a way that i can combine two variables X and a number and use that to reference a variable? In other words can i use a string to reference a variable?
Asked
Active
Viewed 24 times
1
-
You'll need to use Reflection probably to do such a thing. But that shouldn't be required for normal problems. You may want to rethink your approach to solving the problem. – Jeff B May 15 '15 at 20:59
-
You could switch to an array. – Raymond Chen May 15 '15 at 22:28
1 Answers
0
Use Dictionary. Where key is a string: your variable name. And value is the value assigned to it.
Take a look at the answer to this: Create dynamic variable name

Community
- 1
- 1

Eternal Noob
- 2,717
- 5
- 27
- 41