访问量: 181次,访客数: 181人,浏览量: 1次 
首页  编辑  

通过方法名调用方法

Tags: /C#/RTTI/   Date Created: Tue Jun 10 2008 01:18:26 GMT+0000 (Coordinated Universal Time)

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();

}