I want to display attribute of an object based on the input string . If input is "x" and Object is "obj", i want to display something like "obj.x" without using if,switch or other conditional operators. Can someone help me?
public void My_Method(String input)
{
MyClass tempVariable=getMyClass();
display something like ----> tempVariable.input
}
public getMyClass()
{
MyClass value = MyClass();
value.x=10;
value.y=20;
.........
return value;
}
public class MyClass
{
public int x {get;set;}
public int y {get ;set;}
......
}
The purpose of this is as follows Im receiving a dynamic ExpanObject type from a API. There will a lot of name value pairs and one name value pair contains value as comma separated list of some variable names. I have to get the value of these variables