有一个字符变量存储的是调用一个函数的语句. String str = "Function1();";
有什么方法让这个字符变量在语句中变得好像就在调用这个变量中的函数一样? str;
简单代码如下:
private void button1_Click(object sender, System.EventArgs e)
{
String str = "Function1();";
str; // 用什么方面可以让这个str变成"Function1();"
}public void Function1()
{
MessageBox.Show("Function1");
}谢谢!
有什么方法让这个字符变量在语句中变得好像就在调用这个变量中的函数一样? str;
简单代码如下:
private void button1_Click(object sender, System.EventArgs e)
{
String str = "Function1();";
str; // 用什么方面可以让这个str变成"Function1();"
}public void Function1()
{
MessageBox.Show("Function1");
}谢谢!
http://dev.csdn.net/develop/article/31/31905.shtm
{
string str = "Function1";
Microsoft.VisualBasic.Interaction.CallByName(this,str,Microsoft.VisualBasic.CallType.Method);
} public void Function1()
{
MessageBox.Show("Function1");
}
{
MessageBox.Show("Function1");
} private void button1_Click(object sender, System.EventArgs e)
{
System.Reflection.MethodInfo m=this.GetType().GetMethod("Function1");
m.Invoke(this,null);
}
{
get
{
return function();
}
}
......
string function()
{
......
}
......
f="";
哈哈,最烂的方法。反射好!