Пример #1
0
        public static void InvokeSpecificMethod()
        {
            var p = new Person2 {
                Name = "Frank Olivarez"
            };
            var type   = p.GetType();
            var result = type.GetMethod("Speak").Invoke(p, null);

            Console.WriteLine(result);
        }
Пример #2
0
        public static void GetMethods()
        {
            var p = new Person2 {
                Name = "Jesse Olivarez"
            };
            //Console.WriteLine(p.Speak());
            var type    = p.GetType();
            var methods = type.GetMethods();

            foreach (var method in methods)
            {
                Console.WriteLine(method.Name);
            }
        }