How can I get the value of a parameter of a method in vb.net?

Posted on 2013-01-21
Medium Priority
Last Modified: 2013-11-13

I want to get the value of a parameter of the method being used. How is it possible? Can i use reflection to do this task?

Thanks in advance
Question by:hc_gupta
  • 3
LVL 53

Expert Comment

ID: 38800678
Can you give an example of what you are achieving ?

Using Reflection to analyze Parameters and their values

Accepted Solution

hc_gupta earned 0 total points
ID: 38800711
Basically I'm trying to get the values of the parameters of the current method using  " System.Reflection.MethodBase.GetCurrentMethod.GetParameters ".
Here I'm getting the array of the parameters but I'm interested in getting their values.

For Example

Public Function method1(ByVal name As String, ByVal marks As Integer) As String
Dim detail As String = name & " got " & marks & " marks."
Dim val As Object = System.Reflection.MethodBase.GetCurrentMethod.GetParameters
Dim val2 As Type = val(0).GetType()

Dim val3 As ParameterInfo =...??   '(wat to use here)

Return detail
End Function

how can i get the values of "name" and "marks"??

Author Comment

ID: 39469440
Sorry, but i didn't find the exact solution required .

Author Closing Comment

ID: 39475832
Sorry, but i didn't find the exact solution required .

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
Simple Linear Regression

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question