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;
}这个类 进行匹配,如果在这个类里面已经有这个数据就报错
{
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;
}这个类 进行匹配,如果在这个类里面已经有这个数据就报错
List<string> list=new List<string>
list.AddRange("abc,bca,nnn,eee".Slipt(",".ToCharArray()))foreach(string s in getAllProducts())
{
if(list.Contains(s))
{
//报错
}
}
{
if(dr[""].ToString()!=""&...)
{
textbox1.Text+=dr["ProductLine"].ToString();
}
}
分割foreach(string s in textbox1.Text.Split(','))
{}
判断是否存在list.contains
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>");
}这样应该可以