Is Method Exists
Checks whether a method with the specified name exists in the given object.
- Returns False if containingObject is Nothing or if methodName is null or empty.
- Uses reflection to check both public and non-public, instance and static methods.
- Returns True if a method with the exact name is found; otherwise, False.
VB
Public Function IsMethodExists(containingObject As Object, methodName As String) As Boolean
If containingObject Is Nothing OrElse String.IsNullOrEmpty(methodName) Then Return False
Dim type As Type = containingObject.GetType()
Dim method As MethodInfo = type.GetMethod(methodName,
BindingFlags.Public Or
BindingFlags.NonPublic Or
BindingFlags.Instance Or
BindingFlags.Static)
Return method IsNot Nothing
End Function