Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8467071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:32:06+00:00 2026-06-10T15:32:06+00:00

I have the current method example: public void MethodName(string param1,int param2) { object[] obj

  • 0

I have the current method example:

public void MethodName(string param1,int param2)
{
    object[] obj = new object[] { (object) param1, (object) param2 };
    //Code to that uses this array to invoke dynamic methods
}

Is there a dynamic way (I am guessing using reflection) that will get the current executing method parameter values and place them in a object array? I have read that you can get parameter information using MethodBase and MethodInfo but those only have information about the parameter and not the value it self which is what I need.

So for example if I pass “test” and 1 as method parameters without coding for the specific parameters can I get a object array with two indexes { “test”, 1 }?

I would really like to not have to use a third party API, but if it has source code for that API then I will accept that as an answer as long as its not a huge API and there is no simple way to do it without this API.

I am sure there must be a way, maybe using the stack, who knows. You guys are the experts and that is why I come here.

Thank you in advance, I can’t wait to see how this is done.

EDIT

It may not be clear so here some extra information. This code example is just that, an example to show what I want. It would be to bloated and big to show the actual code where it is needed but the question is how to get the array without manually creating one. I need to some how get the values and place them in a array without coding the specific parameters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:32:07+00:00Added an answer on June 10, 2026 at 3:32 pm

    Using reflection you can extract the parameters name and metadata but not the actual values :

      class Program
        {
            static void Main(string[] args)
            {
                Program p = new Program();
                p.testMethod("abcd", 1);
                Console.ReadLine();
            }
    
            public void testMethod(string a, int b)
            {
                System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
                StackFrame sf = st.GetFrame(0);
                ParameterInfo[] pis = sf.GetMethod().GetParameters();
    
                foreach (ParameterInfo pi in pis)
                {
                    Console.Out.WriteLine(pi.Name);
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's suppose I have some method that returns a IEnumerable<int> object. This methods make
Drupal Question: Does anyone have a method of using Views and highlighting a selected/current
Paramiko's SFTPClient apparently does not have an exists method. This is my current implementation:
Imagine the following simple code: public void F<T>(IList<T> values) where T : struct {
public void MoveMyButton (int x) //where the button suppose to move to { TranslateAnimation
I have following test [Test] public void aaa() { CallContext.LogicalSetData(aa, 1); Action parallelMethod =
This is a contrived example: public static class MyExtensions { public static void MyMethod(
Say I have some code like namespace Portal { public class Author { public
I have a piece of code like the following: public class ActivityHelper { public
I have the following application_controller method: def current_account @current_account ||= Account.find_by_subdomain(request.subdomain) end Should I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.