在c#中把字符串转为变量名并获取变量值的小例子(转)
public class Program
{
public string str = "spp";
public string spp = "Hello World!";
public static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine(p.GetType().GetField(p.str).GetValue(p).ToString());
Console.ReadKey();
}
}