根据属性公开属性的名字(字符串)获取对应属性的值
using System;
namespace ConsoleApplication1
{
public class Program
{
string str = "spp";
public string spp = "Hello World!";
public static void Main(string[] args)
{
Program p = new Program();
p.test();
}
void test()
{
Console.WriteLine(this.GetType().GetField(this.str).GetValue(this).ToString());
Console.ReadKey();
}
}
}