Get Methods - CSharp System.Reflection

CSharp examples for System.Reflection:MethodInfo

Description

Get Methods

Demo Code


using System.Reflection;
using System.Linq;
using System.Collections.Generic;
using System;//w w w. jav a 2 s . c  om

public class Main{
        public static IEnumerable<MethodInfo> GetMethods(this Type type, BindingFlags bindingFlags)
        {
            return type.GetTypeInfo().DeclaredMethods.Where(m => IsConformWithBindingFlags(m, bindingFlags));
        }
        public static IEnumerable<MethodInfo> GetMethods(this Type type, string name)
        {
            return type.GetTypeInfo().DeclaredMethods.Where(m => m.Name == name);
        }
        public static IEnumerable<MethodInfo> GetMethods(this Type type)
        {
            return type.GetTypeInfo().DeclaredMethods;
        }
}

Related Tutorials