Possible Duplicate:
Property Name and need its value
Hi,
This one should be easy for most people. I'd like to access a normal variable in an object (let's say example) by using a variable value.
E.g.: I have a an array with a list of variable names and I want to get the information from the object by using them. Obviously this is wrong:
string[] variable_names = new string[] {"name", "surname"};
myObject.variable_names[0] = 1;
myObject.variable_names[1] = 1;
In other languages (not C#) I use:
myObject[variable_names[0]] = 1;
I know the example looks stupid but it was just a way of explaining it.
Thanks in advance :)