Getting all Methods of Class using Reflection C#

Helps to Get all the Methods from the Class.

public void GetMethodsUsingReflection()
        {
            MethodInfo[] methodInfos = typeof(Student).GetMethods();

            // writes all the property names
            foreach (MethodInfo methodInfo in methodInfos)
            {
                Response.Write(methodInfo.Name + "<br/>");
            }
        }

OUTPUT:

Note it takes base class, current class and property as method if you don't set Binding Flags.

get_Name
set_Name
get_Grade
set_Grade
M1
M2
M3
ToString
Equals
GetHashCode
GetType

Used Class for Demo:

class Student
    {
        private string _name;
        private double _grade;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public double Grade
        {
            get { return _grade; }
            set { _grade = value; }
        }

        public void M1()
        {
            //Code
        }

        public void M2()
        {
            //Code
        }

        public string M3()
        {
            return string.Empty;
        }

        public Student(string name, double grade)

        {
            this.Name = name;
            this.Grade = grade;
        }
    }

Thanks for reading this article. Have a nice day.