title: Get Values of Parameters of a Method Regardless their number or type C#
body: <p>I want to get the values of parameters of any method even if they have different number of parameters using C#
  for example if you have 3 methods as the following:</p>
  
  <pre><code>public void method1 (string param1)
  {
      List&lt;string&gt; parametervalues = getParameters(this.Method);
  }
  public void method2 (int param1, string param2)
  {
      List&lt;string&gt; parametervalues = getParameters(this.Method);
  }
  public void method3 (string param1, int param2, bool param3)
  {
      List&lt;string&gt; parametervalues = getParameters(this.Method);
  }
  </code></pre>
  
  <p>so in getParameters method it will take the methodname and return as a list of strings the values of the parameters regardless number of the parameter is there.</p>
  
  <p>i reached a point that i can get the number of parameters but without values as the following</p>
  
  <pre><code>var method = MethodInfo.GetCurrentMethod();
  var parameters = method.GetParameters();
  List&lt;string&gt; parameterList = new List&lt;string&gt;();
  if (parameters.Length &gt; 0)
  {
      foreach (var p in parameters)
      {
          parameterList.Add(p.Name);
      }
  }
  </code></pre>
  
  <p>UPDATE: </p>
  
  <p>I have found a another way by using (params object[] values) as method parameter as the following</p>
  
  <pre><code>method1(string a, string b, string c)
  {
  list&lt;string&gt; = getParameterasList(a,b,c);
  }
  
  getParameterasList(params object[] values)
  {
              List&lt;string&gt; parameterList = new List&lt;string&gt;();
              if (values.Length &gt; 0)
              {
                  foreach (var v in values)
                  {
                      parameterList.Add(v.ToString());
                  }
              }
  return parameterList;
  }
  </code></pre>