无法将字符串转换为类类型 [英] Cannot Convert string to class type

查看:141
本文介绍了无法将字符串转换为类类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

当我运行这行时,我收到一个错误:


obj.number_type = dropdownlist1.selectedItem.value;


number_type是一个类类型,我想从下拉列表中输入一个字符串值。


这是错误:


无法将类型隐式转换为''TEL.MODEL.TEL_T_NUMBER_TYPE。

请帮助:(

hi there,

When I run this line I get an error:

obj.number_type = dropdownlist1.selectedItem.value;

number_type is a class type and I want to put a string value in it from a drop down list.

this is the error:

Cannot implicitly convert type to ''TEL.MODEL.TEL_T_NUMBER_TYPE.
please help :(

推荐答案


number_type是类类型
number_type is a class type



然后你需要在Number_Type类中添加一个属性来接收字符串


obj.number_type.TelType

Then you need to add a property to your Number_Type class to receive the string

obj.number_type.TelType


我试过了,但它给了我这个错误:


输入字符串格式不正确


:(
I tried that but it gives me this error:

Input String was not in correct Format

:(


我认为你是/正在走上正轨。

错误消息告诉您它不知道如何转换您的类型Tel.Model。 Tel_T_Number_type"到一个字符串。

你需要这样做,然后把那个字符串发送到你的班级。


可能类似于:

obj.number_type.TelType = dropdownlist.selecteditem.value。 ToString();
I think you were/are on the right track.
The error message is telling you that it doesn''t know how to convert your type "Tel.Model.Tel_T_Number_type" to a string.
You need to do that, then send that string to your class.

Probably something like:
obj.number_type.TelType = dropdownlist.selecteditem.value.ToString();


这篇关于无法将字符串转换为类类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆