Hi Tino,
Based on my understanding, what you want to do is to access an
variable(Var2) by using another variable(Var1)'s value., which is a name
string.
I think this feature is usually supported by scripting programming
language, i.e. the language will execute code line one by one.
Implementing such a feature is resource-consuming and can cause performance
hit, so compiled languages like C/C++,VB, VB.NET and etc. never supported
the feature.
In such languages, compiler usually does not maintain variable names in the
executables so identifying a variable though a string name is not feasible.
Some controls (not the language) themselves maintain a name so they can be
identified using a name string, like for Controls in VB.
In .NET if you just want to identify a field (not local variables) you can
achieve that by using the reflection as Ken said. You may refer the article
in MSDN.
Dynamically Loading and Using Types
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpcondynamicallyloadingusingtypes.asp
If you simply want to bind two variables together so changing one will
cause the other to change as well you can use a reference type (class) to
encapsulate the value.
Can you tell me what do you want to do in the project?
I think there may be a better solution for you.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure!
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.