How can I convert a string to variable in c# or C++?
example (vb6):
dim a as string
dim b as string
b="halo"
a="b"
msgbox a
this should make a output = halo
is this possible?..,
thanks for the replies
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit:
I first misunderstood your answer, but now I see (thx Gserg) that you wish to find a variable based on the name. In C# you have to do this via reflection. See the following code snippet, and make sure that you have referenced System.Reflection.
Here I look up the field “FieldName” in that class and then I return the value of the field
See also the MSDN page for GetField http://msdn.microsoft.com/en-us/library/system.type.getfield(v=vs.71).aspx