c#,method,name,reflection

Kerim 8/13/2016 0

This sample code shows how to Get Method Names using Reflection

C#
 using System.Reflection;

// get all public static methods of MyClass type
MethodInfo[] methodInfos = typeof(MyClass).GetMethods(BindingFlags.Public |
                                                      BindingFlags.Static);
// sort methods by name
Array.Sort(methodInfos,
        delegate(MethodInfo methodInfo1, MethodInfo methodInfo2)
        { return methodInfo1.Name.CompareTo(methodInfo2.Name); });

// write method names
foreach (MethodInfo methodInfo in methodInfos)
{
  Console.WriteLine(methodInfo.Name);
}
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments