How can I reference a public variable in a class NOT using dot syntax, but some way where I can use a dynamic variable name?
For example, if I have an object like this:
I know I can reference speed like this:
but I want to reference it like this:
You could use a HashTable, like an array where the index can be a string. Or look into 'eval' on the MSDN
answered Nov 09 '11 at 10:00 PM
You could easily do what you want using reflection, but I think it would introduce a performance hit and increase the size of your executable.
I believe it's possible to override the  operator in C# (if you must use that exact syntax) but I'm not sure.
Just out of curiosity... Why do you ask?
Is it because you're trying to translate and/or work with php code?