C#里面中将字符串转为变量名

 public partial class Form1 : Form
    {
        string str = "spp";
        public string spp = "very good";

        public Form1()
        {
            InitializeComponent();

            MessageBox.Show(this.GetType().GetField(str).GetValue(this).ToString());
        }
    }
posted @ 2013-08-18 15:49  Cad人生  阅读(1640)  评论(0编辑  收藏  举报