Calling a variable with a variable

Feb 27 2014 5:57 AM
So I posted the same question but with calling a label with a variable
(http://www.c-sharpcorner.com/Forums/Thread/246996/)

Now I need to call a variable with a variable.
I've tried to modify the code given in the before mentioned thread, but with no luck.
So my question, can it be done? And if so, how?

Saying I have a variable called Cookie, I need to call the variable that equals what is written in the Cookie variable.
Say, Cookie = "Cake"; I would wanna call the Cake variable.

As mentioned I've tried modifying the code given to the label question (thread as mentioned before), but it didn't work. Here's the code I tried:

String TheLabel = (String)this.Controls[cookie];

Please help, I will love you forever if you do :)

Answers (3)