删除数组中某一匹配项

 string str = "1,2,3,4,5";
        string[] strArray = str.Split(',');
        str = "";
        for (int i = 0,k=0; i < strArray.Length; i++)
        {
            if (strArray[i] != "2")
            {
                if (i == 0)
                {
                    str = strArray[i];
                }
                else {
                    str += "," + strArray[i];
                }

                k++;
            }
        }
      
        Response.Write(str);
        Response.End();

 

posted @ 2012-07-31 10:23  xyzhuzhou  阅读(318)  评论(0编辑  收藏  举报