webservice在控制台应用程序中计算总和

本文关键字:计算 应用程序 控制台 webservice | 更新日期: 2023-09-27 18:27:00

不确定是否有人能理解这一点,但以下是代码:

        case 1:
        double[] myArrai1 = new double[3];
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.BackgroundColor = ConsoleColor.DarkGray;
        Console.WriteLine("*-------------------------------------------------------* ");
        Console.WriteLine("*  Enter an array of numbers to get the sum total       * ");
        Console.WriteLine("*-------------------------------------------------------* ");
        Console.WriteLine("Insert a number");
        myArrai1[0] = double.Parse(Console.ReadLine());
        Console.WriteLine("Insert a number");
        myArrai1[1] = double.Parse(Console.ReadLine());
        Console.WriteLine("Insert a number");
        myArrai1[2] = double.Parse(Console.ReadLine());
        DrawStarLine();
        foreach (double d in myArrai1)
        Console.WriteLine( d );
        Webservices09004961.ServiceReference1.CalculateSumRequest array = new ServiceReference1.CalculateSumRequest();
        //ServiceReference1.CalculateSumRequest array = new ServiceReference1.CalculateSumRequest();
        Webservices09004961.ServiceReference1.ArrayOfDouble arrayOfDoubles = new Webservices09004961.ServiceReference1.ArrayOfDouble(); 
        //CalculateSumOfList.ServiceReference1.Service1SoapClient client = new CalculateSumOfList.ServiceReference1.Service1SoapClient();
        //CalculateSumOfList.ServiceReference1.ArrayOfDouble arrayOfDoubles = new CalculateSumOfList.ServiceReference1.ArrayOfDouble();
        arrayOfDoubles.AddRange(myArrai1);
        double e = array.CalculateSum(arrayOfDoubles); //error on this line CalculateSum?
        Console.WriteLine("=" + e);
        Console.ReadLine();
        break;

我在myArrai1中存储了3个用户输入的数字,我想将其"求和"为sum。我已经制作了一个网络参考CalculateSumOfList。

但它说我的Web引用在我的Web服务中不包含CalculateSum,但它确实包含,我正在同一构建/项目中的windows窗体中使用它?

谢谢。

webservice在控制台应用程序中计算总和

因此,经过一些尝试和错误,我意识到我第一次打电话给客户,这已经用于另一个Web服务。

    case 1:
        double[] myArrai1 = new double[3];
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.BackgroundColor = ConsoleColor.DarkGray;
        Console.WriteLine("*-------------------------------------------------------* ");
        Console.WriteLine("*  Enter an array of numbers to get the sum total       * ");
        Console.WriteLine("*-------------------------------------------------------* ");
        Console.WriteLine("Insert a number");
        myArrai1[0] = double.Parse(Console.ReadLine());
        Console.WriteLine("Insert a number");
        myArrai1[1] = double.Parse(Console.ReadLine());
        Console.WriteLine("Insert a number");
        myArrai1[2] = double.Parse(Console.ReadLine());
        DrawStarLine();
        foreach (double d in myArrai1)
        Console.WriteLine( d );
        Webservices09004961.ServiceReference1.Service1SoapClient client2 = new ServiceReference1.Service1SoapClient();
        Webservices09004961.ServiceReference1.ArrayOfDouble arrayOfDoubles = new Webservices09004961.ServiceReference1.ArrayOfDouble(); 
        arrayOfDoubles.AddRange(myArrai1);
        string e = client2.CalculateSum(arrayOfDoubles);
        Console.WriteLine("=" + e);
        Console.ReadLine();
        break;

所以总结一下(并非双关语),我本可以花5个小时观看和阅读教程,或者在So的帮助下尝试一下!