首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

字符串转换为bool值,该如何处理

2012-02-27 
字符串转换为bool值Boolean.Parse(this.RadioButtonList2.SelectedValue.ToString())为什么说该字符串未

字符串转换为bool值
Boolean.Parse(this.RadioButtonList2.SelectedValue.ToString());
为什么说该字符串未被识别为有效的布尔值,


[解决办法]
if( "true ".equals(this.RadioButtonList2.SelectedValue.ToString())) {

bool bo = Convert.ToBoolean( "true ");

} else if ( "false ".equals(this.RadioButtonList2.SelectedValue.ToString())) {

bool bo = Convert.ToBoolean( "false ");

}

热点排行