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.Re…
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()); } }…
可以实现的方法有: globals(),locals(),eval(),exec() 演示: exce法 In [6]: exec('name="bob"') In [7]: name Out[7]: 'bob' globals用法: In [1]: globals()['name']='bob' In [2]: name Out[2]: 'bob'…