好的,我确实有这样的课。
Namespace mySpace
Public Class ClassA
Private Function MethodA(prm AS Boolean) As Boolean
Return False
End Function
Private Function MethodB() As Boolean
Return False
End Function
End Class
Public Class ClassB
Private Function MethodC() As Boolean
Return True
End Function
Private Function InvokeA() As Boolean
Dim methodObj As MethodInfo
'null pointer except below here
methodObj = Type.GetType("mySpace.ClassA").GetMethod("MethodA")
Dim params As Boolean() = {False}
Return CBool(methodObj.Invoke(New ClassA(), params))
End Function
End Class
End Namespace
我在这里尝试的是使用其方法从具有参数的不同类调用方法。但这会返回一个空指针异常。为什么?我哪里出错了?