首页 新闻 赞助 找找看

c#webservice重载函数报错(新人刚研究webservice)

0
悬赏园豆:5 [待解决问题]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace WebService1
{
    /// <summary>
    /// WebService1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {

        //[WebMethod]
        //public string HelloWorld()
        //{
        //    return "Hello World";
        //}

        public class Products
        {
            public double GetPrice(int ProID)
            {
                return 10;
            }
        }

        [WebMethod(Description="根据产品ID获得产品的价格")]
        public double GetProductPrice(int ProductId)
        {
            Products pros = new Products();
            return pros.GetPrice(ProductId);
        }

        public static int i = 0;
        [WebMethod(Description = "计算", EnableSession = true)]
        public int Count()
        {
            i = i + 1;
            return i;
        }

        [WebMethod(EnableSession = true, MessageName = "CountAdd")]
        public int Count(int da)
        {
            i = i + da;
            return i;
        }

    }
}

以上是我的程序,但是会报错,错误如下:

不如吃茶去的主页 不如吃茶去 | 初学一级 | 园豆:200
提问于:2017-02-10 10:58
< >
分享
所有回答(2)
0

就是不支持咯

吴瑞祥 | 园豆:29449 (高人七级) | 2017-02-10 11:53
0

 

 你起的count方法名一样,有两个count的方法名,webService里不能这样,把方法名换一下就好了

凉夏诺浅 | 园豆:224 (菜鸟二级) | 2017-02-11 16:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册