S
samhng
Hi,
Suppose I have a class:
public class Test
{
public string a;
public int b;
}
Now I want to access the value of variable a of the instance of the
class Test (@_@).
public class App
{
public static void Main(string[] args)
{
Test test = new Test();
test.a = "hello";
test.b = 3;
printValue(t, "a"); //print out the value of field a
}
public void printValue(object obj, string fieldName)
{
// print out the value of the given field name
}
}
My question is what to do in the method printValue(object, string)? Thx!
Suppose I have a class:
public class Test
{
public string a;
public int b;
}
Now I want to access the value of variable a of the instance of the
class Test (@_@).
public class App
{
public static void Main(string[] args)
{
Test test = new Test();
test.a = "hello";
test.b = 3;
printValue(t, "a"); //print out the value of field a
}
public void printValue(object obj, string fieldName)
{
// print out the value of the given field name
}
}
My question is what to do in the method printValue(object, string)? Thx!