【问题标题】:cannot implicity convert type int to 'string'无法将 int 类型隐式转换为“字符串”
【发布时间】:2018-10-29 14:38:36
【问题描述】:

我收到此错误,但不知道如何修复它

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

任何帮助将不胜感激

【问题讨论】:

标签: c#


【解决方案1】:

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

您可以使用 .toString(); 转换结果

> txtLastName.Text = Customers[cboCustomerInfo.SelectedIndex].Excursion.ToString();

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多