protected string IsExistsUser(string Users)
{
string[] u = Users.Split(',');
ArrayList lst = new ArrayList(u);
ArrayList lst1 = new ArrayList();
for (int i = 0; i < u.Length; i++)
{
for (int j = i + 1; j < u.Length; j++)
{
if (u[i].Equals(u[j]))
{
lst1.Add(u[i]);
}
}
}
foreach (string s in lst1)
{
lst.Remove(s);
}
string str = string.Join(",", (string[])lst.ToArray(typeof(string))); return str;
}
在记几个常用的转换用法(ArrayList、string、string[]之间的转换): 1、ArrarList 转换为 string[] :
ArrayList list = new ArrayList();
list.Add("aaa");
list.Add("bbb");
//转换成数组
string[] arrString = (string[])list.ToArray(typeof( string)) ;
2、string[] 转换为 ArrarList :
ArrayList list = new ArrayList(new string[] { "aaa", "bbb" });
3、ArrayList 转换为 string :
ArrayList list = new ArrayList();
list.Add("aaa");
list.Add("bbb");
//转换成数组
string str= string.Join(",", (string[])list.ToArray(typeof( string)));
4、string 转换为 ArrayList :
string str="1,2,3,4,5";
ArrayList b = new ArrayList( str.Split(',') ) ;