Enum & overload & Reflection

来源:互联网 发布:seo闪电精灵怎么样 编辑:程序博客网 时间:2024/06/03 22:44

    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;