2017-10-06 113 views
0

在Python中我可以很容易地做到这一点,看看为re模块的所有方法:有没有办法在C#中查看给定类实例的所有方法?

>>> import re 
    >>> dir(re) 
    ['DEBUG', 'DOTALL', 'I', 'IGNORECASE', 'L', 'LOCALE', 'M', 'MULTILINE', 'S', 'Scanner', 'T', 'TEMPLATE', 'U', 'UNICODE', 'VERBOSE', 'X', '_MAXCACHE', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__version__', '_alphanum', '_cache', '_cache_repl', '_compile', '_compile_repl', '_expand', '_locale', '_pattern_type', '_pickle', '_subx', 'compile', 'copy_reg', 'error', 'escape', 'findall', 'finditer', 'match', 'purge', 'search', 'split', 'sre_compile', 'sre_parse', 'sub', 'subn', 'sys', 'template'] 

我可以给定类的任何实例做同样的。 C#能做到这一点吗?

+0

如果您只是在编程时想这样做,请键入“re”。 - intellisense会在点后弹出一个成员列表。 –

回答

0

是的,你可以使用反射为宗旨,运用GetMethods()功能像

(typeof(yourclass)).GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly); 
相关问题