abc,bca,nnn,eee用SLIPT弄成字符串数组,请问怎么样和public String[] getAllProducts()
    {
        DataSet dsProducts = rd.GetProductList("%");
        int len = dsProducts.Tables[0].Rows.Count;
        String[] AllProducts = new String[len-3];
        int i = 0;
        for (int n = 0; n < len; n++)
        {
            if (dsProducts.Tables[0].Rows[n]["Product"].ToString() != "All Product" && dsProducts.Tables[0].Rows[n]["Product"].ToString() != "Map Maker" && dsProducts.Tables[0].Rows[n]["Product"].ToString() != "Mobile Maps")
            {
                AllProducts[i] = dsProducts.Tables[0].Rows[n]["ProductLine"].ToString();
                i++;
            }
        }
        AllProducts[i++] = "Map Maker";
        AllProducts[i++] = "Mobile Maps";
        return AllProducts;
    }这个类 进行匹配,如果在这个类里面已经有这个数据就报错

解决方案 »

  1.   


    List<string> list=new List<string>
    list.AddRange("abc,bca,nnn,eee".Slipt(",".ToCharArray()))foreach(string s in getAllProducts())
    {
    if(list.Contains(s))
    {
    //报错
    }
    }
      

  2.   

    呵呵,我说的abc,bca,nnn,eee只是比喻,其实是一个TEXTBOX里面要填写的数据,但是必须用逗号隔开,那如果要填写的数据该怎么写啊?新手啊。。别介意
      

  3.   

    foreach(DataRow dr in ds.Tables[0].Rows)
    {
     if(dr[""].ToString()!=""&...)
    {
    textbox1.Text+=dr["ProductLine"].ToString();
    }
    }
    分割foreach(string s in textbox1.Text.Split(','))
    {}
    判断是否存在list.contains
      

  4.   


     try
            {
                string kk = "abc,bca,nnn,eee";
                string[] arryString = kk.Split(',');
                string[] arrySt = getAllProducts();//调用你的方法
                for (int i = 0; i < arryString.Length; i++)
                {
                    for (int j = 0; j < arrySt.Length; j++)
                    {
                        if (arrySt[j] == arryString[i])
                        {
                            continue;
                        }
                        else
                        {
                            throw new Exception(arryString[i] + "已存在");
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {            ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('"+ex.Message+"');</script>");
            }这样应该可以