title: Convert list to int array in C#
body: <p>I have searched through StackOverflow and Google for the conversion, but unfortunately I was unable to get the solution. Everything was the opposite of what I wanted. i.e., Conversion of an <code>int[]</code> to <code>List</code>.</p>
  <p><strong>Problem</strong></p>
  <p>I have this code in my <code>[WebMethod]</code>.</p>
  <pre><code>[WebMethod]
  public int MyMethodWS(int N, List&lt;int&gt; M)
  {
  }
  </code></pre>
  <p>And now I have a <strong>Console Application</strong>, that references this service by using this URL:</p>
  <pre><code>http://localhost:61090/MyMethod.asmx?WSDL
  </code></pre>
  <p>I have this code in my Console Application:</p>
  <pre><code>int N;
  List&lt;int&gt; M = new List&lt;int&gt;();
  // Some crazy user input coding.
  // Ultimately you will have non-empty M list and N int.
  MyMethod.MyMethodWS DA = new MyMethod.MyMethodWS();
  Sum = DA.MyMethodWS(N, M);
  </code></pre>
  <p>When I run this code, I am getting this error:</p>
  <blockquote>
  <p><strong>#1:</strong> The best overloaded method match for '<code>MyMethod.MyMethod.MyMethodWS(int, int[])</code>' has some invalid arguments.</p>
  <p><strong>#2:</strong> Argument 2: cannot convert from '<code>System.Collections.Generic.List&lt;int&gt;</code>' to '<code>int[]</code>'</p>
  </blockquote>
  <p><strong>Questions</strong></p>
  <ol>
  <li>I have used only <code>List</code> there. But why is it trying to convert as <code>int[]</code>?</li>
  <li>Currently the WebService as well as Console Application, both run in the same Solution. Is it a problem? Should I use different solutions, or different instances of Visual Studio 2012 altogether?</li>
  </ol>