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 658815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:58:31+00:00 2026-05-13T22:58:31+00:00

The problem i’m having is that i’ve created a web service, and a windows

  • 0

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<int>

The web service code is as follows:

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<int> listInt)
        {
            int sum = listInt.Sum();
            return sum;
        }
    }
}

and the client code is:

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<int> intArray = new List<int>();

        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 < 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);
        }
    }
}

The error I am getting is:

Argument ‘1’: cannot convert from ‘System.Collections.Generic.List’ to ‘CalculateForm.CalculateService.ArrayOfInt’

I am sure it’s something simple and I’ll feel daft when someone points it out 🙂

Cheers
Carl

  • 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-05-13T22:58:31+00:00Added an answer on May 13, 2026 at 10:58 pm

    I finally got it working!! 🙂

    I managed to get it to pass the List<int> rather than using the ToArray() method.

    Here’s the client code:

    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    
    namespace CalculateForm
    {
        public partial class FormCalculate : Form
        {
            List<int> listInt = new List<int>();
    
            public FormCalculate()
            {
                InitializeComponent();
            }
    
            private void btnAddNum_Click(object sender, EventArgs e)
            {
                listInt.Add(Convert.ToInt32(txtAddNum.Text));
                txtAddNum.Clear();
                listBoxAddNum.Items.Clear();
    
                for (int i = 0; i < listInt.Count; i++)
                {
                    listBoxAddNum.Items.Add(listInt[i]);
                }
            }
    
            private void btnCalculate_Click(object sender, EventArgs e)
            {
                CalculateService.Service1SoapClient client = new CalculateService.Service1SoapClient();
    
                CalculateService.ArrayOfInt arrayOfInt = new CalculateService.ArrayOfInt();
    
                arrayOfInt.AddRange(listInt);
    
                int result = client.CalcluateSum(arrayOfInt);
    
                txtResult.Text = Convert.ToString(result);
            }
        }
    }
    

    and the web service 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<int> listInt)
            {
                int sum = listInt.Sum();
                return sum;
            }
        }
    }
    

    so basically all I had to do was create a new instance of the CalculateService.ArrayOfInt in the client, and add the range of data from the List<int> listInt then pass arrayOfInt to the web service.

    Cheers everyone for your help, no doubt I’ll be back soon 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 428k
  • Answers 428k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I suggest using Boost.Python as suggested by ChristopheD. A gotcha… May 15, 2026 at 1:09 pm
  • Editorial Team
    Editorial Team added an answer Apparently you can't. x86 compilation will occur with VS 2008… May 15, 2026 at 1:09 pm
  • Editorial Team
    Editorial Team added an answer The value of your hidden field is not an array,… May 15, 2026 at 1:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.