2017-10-06 79 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); 
相關問題