作者:aixiangsui2011 | 来源:互联网 | 2023-09-06 12:44
publicvoidGetSettings(){DataSetdsSettingsnewDataSet();dsSettings.ReadXml(MapPath(d
public void GetSettings()
{
DataSet dsSettings = new DataSet();
dsSettings.ReadXml(MapPath("data/config.xml"));
DataView dvSettings = new DataView(dsSettings.Tables["main"]);
switch (dvSettings[0]["register"].ToString)
{
case "False": /*出错信息:Cannot implicitly convert type 'string' to 'method group'*/
allow_registration.SelectedIndex=1;
case "True":
allow_registration.SelectedIndex=0;
}
smtpserver.Text = dvSettings[0]["smtpserver"].ToString; /*出错信息:Cannot convert method group 'ToString' to non-delegate type 'string'.*/
rsstitle.Text = dvSettings[0]["rsstitle"].ToString;
rssdesc.Text = dvSettings[0]["rssdesc"].ToString;
rsscopy.Text = dvSettings[0]["rsscopy"].ToString;
}
9 个解决方案
dvSettings[0]["register"].ToString() //这里没出错?
ToString后面没有加()的过,加上就OK了
如rsstitle.Text = dvSettings[0]["rsstitle"].ToString();
switch (dvSettings[0]["register"].ToString--->
switch (dvSettings[0]["register"].ToString()
还有,照你写的dvSettings[0]["register"]应该是bool字段吧!
既然那为什么这么比较??
直接
bool b = dvSettings[0]["register"];
if(b)
{
}else
{
}
不就可以了?
要强制类型转换:
(bool) dvSettings[0]["register"];
顶!好像CASE后面结束的时候要加BREAK;的啊!楼主好像也没写!
我有个疑问~~为什么vb.net,ToString可以,C#却不行?“()”有和没有到底有什么说法?
现在其他问题没有了,不过这个地方还有错~~~~再帮忙看看~~ps:谢谢楼上的各位
error CS0163: Control cannot fall through from one case label ('case "False":') to another
error CS0163: Control cannot fall through from one case label ('case "True":') to another
用 case "False": /*出错信息:Cannot implicitly convert type 'string' to 'method group'*/
allow_registration.SelectedIndex=1;
break;
case "True":
allow_registration.SelectedIndex=0;
break;
试试