Posts

Showing posts with the label Reflection

Get Method Names using Reflection [C#]

Image
If you want to get method names of a given type in C#, you can use method Type.GetMethods. This method returns array of MethodInfo objects. MethodInfo contains many informations about the method and of course a method name (MethodInfo.Name). To filter returned methods (for example if you want to get only public static methods) use BindingFlags parameter when calling GetMethods method. Required are at least two flags, one from Public/NonPublic and one of Instance/Static flags. Of course you can use all four flags and also DeclaredOnly and FlattenHierarchy. BindingFlags enumeration and MethodInfo class are declared in System.Reflection namespace. The example will show method name and return type of the method of developersnote class The developersnote Class     public class developersnoteClass     {         public developersnoteClass()         {         }         public void ConvertDateTime()         {         }         public static void ConvertInteger()         {         }         publ