首页  编辑  

通过方法名调用方法

Tags: /C#/RTTI/   Date Created:

using System . Reflection;

public string HelloWorld( string AName)

{

   return "{Hello world " + AName + "}" ;

}

private void button1_Click( object sender , EventArgs ce)

{

    MethodInfo vMethodInfo = GetType() . GetMethod( "HelloWorld" );

    if (vMethodInfo == null ) return ;

   Text = vMethodInfo . Invoke( this , new object [] { "Zswang" }) . ToString();

}