关于.net项目编码 [英] about .net project coding
本文介绍了关于.net项目编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (DropDownListCreateUserCity.SelectedValue)
{
city = DropDownListCreateUserCity.SelectedValue;
}
else
{
city = txtother.Text;
}
错误:无法将类型字符串"隐式转换为布尔" ....... plz帮我....
error:-cannot implicitly convert type .''string'' to ''bool''.......plz help me....
推荐答案
错误出现在If条件中:
尝试:
The error is in If Condition :
try :
if (DropDownListCreateUserCity.SelectedValue!="")
{
city = DropDownListCreateUserCity.SelectedValue.ToString();
}
else
{
city = txtother.Text;
}
此处城市应为字符串类型.
或者您也可以检查SelectedIndex,例如:
here city should be of string type.
or you can check SelectedIndex also, such as :
if (DropDownListCreateUserCity.SelectedIndex > 0)
将city
的声明更改为字符串.
您可能必须将DropDownListCreateUserCity.SelectedValue强制转换为字符串,或者使用ToString方法.
Change the declaration ofcity
to a string.
You may have to either cast DropDownListCreateUserCity.SelectedValue to a string, or use the ToString method.
更改您声明的城市类型,或者您可以检查
city = DropDownListCreateUserCity.SelectedValue.ToString();
change the type of city which u declare or u can check that
city = DropDownListCreateUserCity.SelectedValue.ToString();
这篇关于关于.net项目编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文