日期:2014-05-17 浏览次数:20951 次
String str="2,3,4,3,2,5";
string[] list = str.Split(',');
string ret = string.Empty;
ArrayList list1 = new ArrayList();
for (int i = 0; i < list.Length; i++)
{
if (!list1.Contains(list[i]))
{
list1.Add(list[i]);
}
}
for (int i = 0; i < list1.Count; i++)
{
ret += list1[i] + ",";
}
Console.WriteLine(ret);
Console.Read();
string str = "2,3,5,3,6,7,6,8,5,4,3,2,1,89,54,3,2,45,12,345345,123123,34,3,3,2,";
string[] stringArray = str.Split(',');
List<string> listString = new List<string>();
foreach (string eachString in stringArray)
{
if (!listString.Contains(eachString))
listString.Add(eachString);
}
Console.WriteLine(string.Join(",", listString.ToArray()));
Console.Read();