[WebMethod]
public string[] GetInsName(string prefixText, int count)
{
string[] retstr = new string[20];
strsql = " select InsName from Institution where InsName Like '%" + prefixText + "%'and IsDelete=0 ";
DataTable dt = new DataTable();
dbHelper.FillDataTable(ref dt, strsql); for (int i = 0; i < dt.Rows.Count; i++)
{
retstr[i] = dt.Rows[i]["InsName"].ToString();
}
return retstr.ToArray().Take(dt.Rows.Count);
}代码如下 因为给retstr定义了数量 所以输出整个 数组 数组中没有值的项也会被输出来
现在这个代码 错误提示 无法将类型“System.Collections.Generic.IEnumerable<string>”隐式转换为“string[]”。存在一个显式转换(是否缺少强制转换?)要咋么样 输出retstr 中有值的一项 ????在线等 高手.......
public string[] GetInsName(string prefixText, int count)
{
string[] retstr = new string[20];
strsql = " select InsName from Institution where InsName Like '%" + prefixText + "%'and IsDelete=0 ";
DataTable dt = new DataTable();
dbHelper.FillDataTable(ref dt, strsql); for (int i = 0; i < dt.Rows.Count; i++)
{
retstr[i] = dt.Rows[i]["InsName"].ToString();
}
return retstr.ToArray().Take(dt.Rows.Count);
}代码如下 因为给retstr定义了数量 所以输出整个 数组 数组中没有值的项也会被输出来
现在这个代码 错误提示 无法将类型“System.Collections.Generic.IEnumerable<string>”隐式转换为“string[]”。存在一个显式转换(是否缺少强制转换?)要咋么样 输出retstr 中有值的一项 ????在线等 高手.......
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货