编译器错误信息: CS0029: 无法将类型“int []”隐式转换为“string”
publicint[]FindPositions(stringstrSource,stringstrKey){//这里由hlxwell提供MatchCollectionm...
public int[] FindPositions(string strSource, string strKey)
{
//这里由hlxwell提供
MatchCollection mc = Regex.Matches(strSource, strKey);
string a = "";
foreach (Match m in mc)
{
//把所有位置用,隔开
a += m.Index + ",";
}
//根据,把位置的值分开来
string[] s = a.Split(',');
int[] sPosition = new int[s.Length - 1];
for (int i = 0; i < s.Length - 1; i++)
{
sPosition[i] = Convert.ToInt32(s[i]);
}
return sPosition;
}
//定位截取
public int [] cut(string indexCon, string indexStar)
{
indexCon = "";//要截取的内容
indexStar = "";//截取开头索引
int[] number = FindPositions(indexCon, indexStar);
int len = number[0] + indexStar.Length;
string subs = indexCon.Substring(len, indexCon.Length - len);
int[] number2 = FindPositions(subs,"aa");
string subs2 = subs.Substring(0, number2[0]);
}
private bool getMemberID()
{
string str = "";
string str2 = "";
...........................
..........
str = dr.Rows[0]["PT_Text"].ToString();
str2 = cut(str,"psnotes=");//应用cut方法
this.label2.Text = str2;
}
源错误:
行 156: str2 = cut(str,"psnotes=");//应用cut方法 展开
{
//这里由hlxwell提供
MatchCollection mc = Regex.Matches(strSource, strKey);
string a = "";
foreach (Match m in mc)
{
//把所有位置用,隔开
a += m.Index + ",";
}
//根据,把位置的值分开来
string[] s = a.Split(',');
int[] sPosition = new int[s.Length - 1];
for (int i = 0; i < s.Length - 1; i++)
{
sPosition[i] = Convert.ToInt32(s[i]);
}
return sPosition;
}
//定位截取
public int [] cut(string indexCon, string indexStar)
{
indexCon = "";//要截取的内容
indexStar = "";//截取开头索引
int[] number = FindPositions(indexCon, indexStar);
int len = number[0] + indexStar.Length;
string subs = indexCon.Substring(len, indexCon.Length - len);
int[] number2 = FindPositions(subs,"aa");
string subs2 = subs.Substring(0, number2[0]);
}
private bool getMemberID()
{
string str = "";
string str2 = "";
...........................
..........
str = dr.Rows[0]["PT_Text"].ToString();
str2 = cut(str,"psnotes=");//应用cut方法
this.label2.Text = str2;
}
源错误:
行 156: str2 = cut(str,"psnotes=");//应用cut方法 展开
2个回答
展开全部
cut方法的返回值不是个int [] 么,而你str2 定义的是string ,int[]的返回值当然不能直接付给string了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询