我需要将字符串作为类的字段名称传递给函数。获取或更新函数中类的值。有可能做得到吗?
//Try to describe the question as following code...
public class TEST {
public string DATA1 { set; get; }
}
string param = "DATA1"; //DATA1 is one of the field of class TEST
private void GrabFieldData(string param) {
string str = TEST.param; //grab the value of TEST.DATA1
}
private void UpdateFieldData(string param) {
string str = "new data";
TEST.param = str; //update the value of TEST.DATA1
}