using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 结构
{
class Program
{
static void Main(string[] args)
{
//List用于存储从数组里取出来的不相同的元素List<string> listString = new List<string>()
string[] stringArray = { "aaa", "bbb", "aaa", "ccc", "bbb", "ddd", "ccc", "aaa", "bbb", "ddd" };
List<string> listString = new List<string>();
foreach (string eachString in stringArray)
{
if (!listString.Contains(eachString))
listString.Add(eachString);
}//最后从List里取出各个字符串进行操作
foreach (string eachString in listString)
{
Console.Write(eachString); //打印每个字符串}
}
Console.ReadLine();
}
}
}
|