无法将类型int隐式转换为'string'

时间:2018-10-28 23:17:56

标签: c#

我遇到此错误,不知道如何解决

  // validate user selected an item
        if(cboCustomerInfo.SelectedIndex >-1)
        {
            // display items in groupbox
            txtLastName.Text = Customers[cboCustomerInfo.SelectedIndex].Excursion;
            if(Customers [cboCustomerInfo .SelectedIndex].Excursion ==1)
            {
                rdoNatureTrail.Checked = true;
            }
            else if (Customers[cboCustomerInfo .SelectedIndex ].Excursion ==1)
            {
                rdoBoatExcursion.Checked = true;
            }
            else
            {
                rdoKayakTour.Checked = true;
            }
            // endable groupbox
            grpNatureExcursion.Enabled = true;

            // set tag group box to index of job
            grpNatureExcursion.Tag = cboCustomerInfo.SelectedIndex;

        }

此语句有误:

  

txtLastName.Text=Customers[].Excursion

任何帮助将不胜感激

2 个答案:

答案 0 :(得分:0)

从客户那里游览的方法是什么?它返回一个INT?

您可以使用.toString();

强制转换结果
> txtLastName.Text = Customers[cboCustomerInfo.SelectedIndex].Excursion.ToString();

答案 1 :(得分:0)

表示它的意思,它不能将int隐式转换为字符串。使用ToString()进行转换