MethodInfo.Invoke : MethodInfo « System.Reflection « VB.Net by API






MethodInfo.Invoke

  
Imports System
Imports System.Reflection

 
Public Class MainClass

    Shared Sub Main(  )
         Dim theMathType As Type = Type.GetType("System.Math")

         Dim paramTypes(0) As Type
         paramTypes(0) = Type.GetType("System.Double")

         Dim ConsineInfo As MethodInfo = _
             theMathType.GetMethod("Sin", paramTypes)

         Dim parameters(0) As Object
         parameters(0) = 45 * (Math.PI / 180)
         Dim returnVal As Object

         returnVal = ConsineInfo.Invoke(theMathType, parameters)
         Console.WriteLine("The sine of a 45 degree angle is {0}", _
             returnVal)
    End Sub
  
End Class

   
    
  








Related examples in the same category

1.MethodInfo.GetCustomAttributes
2.MethodInfo.GetParameters()
3.MethodInfo.Name