public enum dx:int
{
dx1 = 1,
dx2 = 2,
dx3 = 3,
dx4 = 4
}
class Class3
{
public void Fun(dx x)
{
MessageBox.Show("1_"+((int)x).ToString());
}
public void Fun(string x, string y)
{
MessageBox.Show("2_"+x + y);
}
public void Fun(string x,int y)
{
MessageBox.Show("3_"+x+y.ToString() );
}
}
//Reflection:
object obj = System.Activator.CreateInstance(t);
System.Reflection.MethodInfo mi = t.GetMethod("Fun1");
string str = mi.Invoke(obj, new object[] { "1", 2 }) as string;
本文介绍了一个使用C#编写的示例程序,该程序定义了一个枚举类型并展示了如何通过反射来实例化对象及调用方法。示例包括了枚举类型的定义、不同重载方法的实现以及反射的具体应用。
1073

被折叠的 条评论
为什么被折叠?



