Wouldn't your code have to be in the method anyway ?

BTW: the code for adding the "," will probably add a "," where not
appropriate and your making unneeded calls to GetParameters() etc. Change to


For i as Integer= 0 ..........
  If i > 0 Then key &= ", "

Cleaned up a little:
      Dim method As MethodBase = MethodBase.GetCurrentMethod()
      Dim params = method.GetParameters
      Dim key As String = method.Name & "("
      For i As Integer = 0 To params.Length - 1
         If i > 0 Then key &= ", "
         Dim ptype = params(i).ParameterType
         key &= If(ptype.IsByRef, "ByRef ", "") & params(i).Name & " As " &
params(i).ParameterType.ToString.TrimEnd("&"c)
      Next
      key &= ")"

Still doesn't answer your question though. I'm not sure you can as it would
be interception so you won't get that via reflection, although you could
probably look in the stack to get the values .....


|-----Original Message-----
|From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-
|boun...@ozdotnet.com] On Behalf Of Anthony Mayan
|Sent: Tuesday, 27 September 2011 11:40 PM
|To: ozDotNet
|Subject: Get Method Argument values?
|
|Using the below cod to retrieve the argument names of the current method
|which works fine..how would would i get the values?
|
|        Dim method As MethodBase = MethodBase.GetCurrentMethod()
|            Dim key As String = method.Name & "("
|            For i As Integer = 0 To method.GetParameters().Length - 1
|                key &= DirectCast(method.GetParameters().GetValue(i),
|System.Reflection.ParameterInfo).Name
|                If i < method.GetParameters().Length - 1 Then
|                    key &= ","
|                End If
|            Next
|            key &= ")"
|
|
|thanks in advance

Reply via email to