当然出错了!
strsq在foreach里面变成了局部变量,外部的string strsq="ddd"在foreach里面已经无效!string strsq="ddd";
int count=0;
foreach(string strs in arraryb)
{
    if(strs.IndexOf(strsq)>0)
    {
       count++;
    }
}

解决方案 »

  1.   

    string strsq="ddd";
    int count=0;
    if (arraryb.IndexOfAny(strsq)>=0)
    {
        count+=1;
    }
      

  2.   

    bolar()
    应该是:
    string strsq="ddd";
    int count=0;
    if (strsq.IndexOfAny(arraryb)>=0)
    {
        count+=1;
    }
      

  3.   

    为什么以上都有字符串数组不能够转换成char [] 的cuowu?
    indexof ,indeofany都是针对char[]数组吗?
    两个有什么区别?///////////
      

  4.   

    谢谢 luohzad(一心一意想成为c#高手)
      

  5.   

    你在Microsoft Visual Studio .NET 文档查String 类里面有说明。
      

  6.   

    最好不要用foreach,它比for慢2倍(平均),我已经测过了,不信,你试试
      

  7.   

    谢谢楼上的各位,交个朋友.
    我的qq 99806311
          email:[email protected]