Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2013-01-21
4
439 Views
Last Modified: 2013-11-13
Sir/Ma'am,

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
0
Comment
Question by:hc_gupta
  • 3
4 Comments
 
LVL 53

Expert Comment

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

Using Reflection to analyze Parameters and their values
http://stackoverflow.com/questions/2147368/using-reflection-to-analyze-parameters-and-their-values
0
 

Accepted Solution

by:
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"??
0
 

Author Comment

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

Author Closing Comment

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

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

828 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