c# - Getting all methods of a target class at runtime -
this question has answer here:
- how list of properties of class? 9 answers
is there way me returned list of methods of target class in form of array of strings @ runtime in c# other parsing documentation class? want emulate ide's suggesting methods types code segment.
so method work (ideally) so:
getmethods(foo.gettype())
and returned list of foo's methods.
using system; using system.linq; namespace consoleapplication1 { class someclass { public void a() { } public void b() { } public void c() { } public void d() { } public void e() { } public void f() { } } class program { static void main() { var methods = getmethods(typeof (someclass)); foreach (var methodname in methods) { console.writeline(methodname); } } private static string[] getmethods(type type) { var methods = type.getmethods(); return methods.select(m => m.name).toarray(); } } }
Comments
Post a Comment