111,094
社区成员




public static void Main()
{
test t = new test();
t.a1 = 10;
string b = "a1";
Type T=t.GetType();
System.Reflection.FieldInfo fi = T.GetField(b);
if (fi != null)
{
int value = (int)fi.GetValue(t);
Console.WriteLine("{0}={1}", b, value);
}
}
struct test
{
public int a1;
public int a2;
public int a3;
}