I’ve got a Class with an undetermined number of methods inside
Public Class MyClass
Public Sub Foo()
End Sub
Public Sub Bar()
End Sub
End Class
Is there an easy way to call all of the methods in “MyClass” without physically specifying each one? The reason for this is that the methods within “MyClass” are going to be evergrowing, and I don’t want to specify the method call for each one when the end goal is to execute every method on a set schedule.
IE: I want to avoid
Page_Load
Foo()
Bar()
Edit:
I’ve tried the following code to loop through the methods, but I’m getting an error
Public Shared Sub Calculator()
Dim methods As New Methods()
For Each Info As MethodInfo In methods.GetType.GetMethods
Info.Invoke(Nothing, Nothing)
Next
End Sub
System.Reflection.TargetException: Non-static method requires a target.
Here’s a simple example, invoking methods without parameters: