简体   繁体   中英

C# Reflection Assembly: getMethods() ignores constructors

As said in title. I tried using Bindingflags but none of them seem to be working:

Assembly assembly = Assembly.LoadFile(somePath);
foreach (var type in assembly.GetTypes())
            {
             foreach(var method in type.GetMethods())
             Console.WriteLine(method.Name);
            }

That's because constructors are not methods (despite some superficial similarities in syntax). For constructors you want Type.GetConstructors ( http://msdn.microsoft.com/en-us/library/vstudio/system.type.getconstructors ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM