我想区分这两种情况,例如以下代码:
For Each method As Reflection.MethodInfo In Type.GetType("WindowsApplication2.clsTest").GetMethods()
Select Case method.Name
Case "ToString", "Equals", "GetHashCode", "GetType"
Case Else
Debug.Print(method.GetType().ToString)
End Select
Next
或者更好的是,是否可以仅对子项或函数进行迭代?
谢谢。
答案 0 :(得分:1)
MethodInfo
类具有ReturnType
属性,而Sub
的返回类型为Void
,因此您可以执行以下操作:
For Each method As Reflection.MethodInfo In Type.
GetType("WindowsApplication2.clsTest").GetMethods().
Where(Function(m) m.ReturnType IsNot GetType(Void))
Select Case method.Name
Case "ToString", "Equals", "GetHashCode", "GetType"
Case Else
Debug.Print(method.Name)
End Select
Next