title: How to pass a List<int> to a service reference (C#, VS2008)
body: <p>The problem i'm having is that i've created a web service, and a windows form (separate solutions).  I added the web service to the form app using a service reference, I can pass an 'int' or a 'string' to the web service no problem, but i cannot pass an array of int's or List<code>&lt;int</code>></p>
  
  <p>The web service code is as follows:</p>
  
  <pre><code>using System.Collections.Generic;
  using System.ComponentModel;
  using System.Linq;
  using System.Web.Services;
  
  namespace CalculateService
  {
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [ToolboxItem(false)]
  
      public class Service1 : System.Web.Services.WebService
      {
          [WebMethod]
          public int CalcluateSum(List&lt;int&gt; listInt)
          {
              int sum = listInt.Sum();
              return sum;
          }
      }
  }
  </code></pre>
  
  <p>and the client code is:</p>
  
  <pre><code>using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace CalculateForm
  {
      public partial class FormCalculate : Form
      {
          List&lt;int&gt; intArray = new List&lt;int&gt;();
  
          public FormCalculate()
          {
              InitializeComponent();
          }
  
          private void btnAddNum_Click(object sender, EventArgs e)
          {
              intArray.Add(Convert.ToInt32(txtAddNum.Text));
              txtAddNum.Clear();
              listBoxAddNum.Items.Clear();
              for (int i = 0; i &lt; intArray.Count; i++)
              {
                  listBoxAddNum.Items.Add(intArray[i]);
              }
          }
  
          private void btnCalculate_Click(object sender, EventArgs e)
          {
              CalculateForm.CalculateService.Service1SoapClient client = new CalculateForm.CalculateService.Service1SoapClient();
              int result = client.CalcluateSum(intArray);
              txtResult.Text = Convert.ToString(result);
          }
      }
  }
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <blockquote>
    <p>Argument '1': cannot convert from 'System.Collections.Generic.List' to 'CalculateForm.CalculateService.ArrayOfInt'</p>
  </blockquote>
  
  <p>I am sure it's something simple and I'll feel daft when someone points it out :)</p>
  
  <p>Cheers
  Carl</p>