string compname="1与3";
String[] name = compname.Split(‘与‘);
string namer=name[0];
namer=1
DataTable dtLabelList;
if (btnAllLabel.Text == "显示全部标签")
dtLabelList = cc.GetDataInfo("", 10);
else
dtLabelList = cc.GetDataInfo("", 100000);//获取数据库表的封装里的信息
string lable = "";
for (int i = 0; i < dtLabelList.Rows.Count; i++)
{
lable += Convert.ToString(dtLabelList.Rows[i].ItemArray[dtLabelList.Columns.IndexOf("LabelName")]) + " ";//获取每个标签信息。
}
string lable1 = "";
String[] strs = lable.Split(‘|‘);//截取
for (int i = 0; i < strs.Length; i++)
{
if (lable1.IndexOf(strs[i].ToString()) <= -1)
{
lable1 += strs[i].ToString() + " | ";//拼接
}
}
LabelList.Text = lable1;
原文:https://www.cnblogs.com/liuguiqing/p/15233478.html