有没有办法在C#中查看给定类实例可用的所有方法?

时间:2017-10-06 18:23:47

标签: c# python

在python中,我可以轻松地查看Sub LoopThroughBlanks() Dim wbk As Workbook Dim ws As Worksheet Dim lRow As Long Dim Cell As Range Set wbk = ActiveWorkbook Set ws = wbk.Worksheets("Sheet1") 'Be sure to change this to your worksheet name! With ws 'Find last row of data in worksheet lRow = .Cells.Find(What:="*", _ After:=.Cells(1, 1), _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row 'Loop through blank cells in col a For Each Cell In .Range("A1:A" & lRow).SpecialCells(xlCellTypeBlanks) If Cell.Row = 1 Then .Range("A1").EntireRow.Insert End If 'Copy to column 26 Cell.Offset(-1, 25).Value = Cell.Offset(0, 1).Value .Rows(Cell.Row).EntireRow.Delete Next Cell End With End Sub 模块的所有方法:

re

对于给定类的任何实例,我都可以这样做。 C#可以这样做吗?

2 个答案:

答案 0 :(得分:0)

是的,您可以将Reflection用于此目的并使用GetMethods()函数,如

(typeof(yourclass)).GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly);

答案 1 :(得分:-1)