反射简单例子

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace ConsoleApplication1
{
    public delegate void MethodDelgate();

    class Program
    {
        static void Main(string[] args)
        {
            Type type = typeof(Press);
            MethodInfo[] info = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
            for (int i = 0; i < info.Length; i++)
            {
                Console.WriteLine(info[i].Name); 
            }
        }
       
    }

    public class Press
    {

        private void test()
        {
            Console.WriteLine("测试....能调得到吗?");
        }
    }
}

 

posted @ 2014-12-27 09:59  kevin.dai  阅读(375)  评论(0编辑  收藏  举报