Enum & overload & Reflection

    技术2022-05-20  28

        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;


    最新回复(0)