C# 无法隐式转换类型';无效';至';字符串';网络服务

C# 无法隐式转换类型';无效';至';字符串';网络服务,c#,web-services,C#,Web Services,我是C#的新手,我不明白为什么会出现这个错误。这是我的密码: public partial class Window : System.Windows.Forms.Form { WebServ.ItemDimWs con = new WebServ.ItemDimWs(); decimal length, width, height, weight, rescode; string user, article, res; public Win

我是C#的新手,我不明白为什么会出现这个错误。这是我的密码:

    public partial class Window : System.Windows.Forms.Form
    {

    WebServ.ItemDimWs con = new WebServ.ItemDimWs();

    decimal length, width, height, weight, rescode;
    string user, article, res;

    public Window()
    {
        InitializeComponent();
    }

    private void Window_Load(object sender, EventArgs e)
    {

    }


    public void btn_send_Click(object sender, EventArgs e)
    {
        length = Convert.ToDecimal(tb_lenght.Text.ToString());
        width = Convert.ToDecimal(tb_width.Text.ToString());
        height = Convert.ToDecimal(tb_height.Text.ToString());
        weight = Convert.ToDecimal(tb_weight.Text.ToString());
        article = tb_article.Text;
        user = tb_user.Text;

        string result = con.setItemDims(article, length, width, height, weight, weight, "EA", "KG", "CM", user, ref rescode, ref res);
        MessageBox.Show(result);
        MessageBox.Show("Resp:" + rescode + res + "!!!");
    }
}

我需要向Web服务发送一些信息并接收答案。

WebServ.ItemDimWs.setItemDims不返回任何内容,因此无法将输出分配给字符串

因此,与其这样做

string result = con.setItemDims(article, length, 
        width, height, weight, weight, "EA", "KG", "CM", 
        user, ref rescode, ref res);
你可以和我一起去

con.setItemDims(article, length, 
        width, height, weight, weight, "EA", "KG", "CM", 
        user, ref rescode, ref res);

您正在将方法的返回值
setItemDims
分配给字符串变量,但该方法无效(无返回值)


注意:不确定
setItemDims
bu的所有参数是什么,我可以看到您正在传递
ref res
,这可能是设置的结果。同样,只是根据命名约定猜测?

因为webservice方法没有返回任何不能这样调用的内容

string result=con.setItemDims(物品、长度、宽度、高度、重量、重量、“EA”、“KG”、“CM”、用户、参考重编码、参考分辨率)

如果您希望输出结果,您可以以这样一种方式写入服务,即结果将是输出参数。(如果您可以通过web服务代码访问。)

con.setItemDims(..)很可能是一个void函数,这意味着它不会返回任何内容,但是您可以尝试将其存储到结果字符串变量中。