try...
static void Main(string[] args)
{
string[] str ={ "a", "b", "c", "a", "a", "c", "b", "c", "a" };
List<string> list = new List<string>();
for (int i = 0; i < str.Length; i++)
{
if (!list.Contains(str[i]))
list.Add(str[i]);
}
for(int i=0;i<list.Count;i++)
Console.WriteLine(list[i]);
}
static void Main(string[] args)
{
string[] str ={ "a", "b", "c", "a", "a", "c", "b", "c", "a" };
List<string> list = new List<string>();
for (int i = 0; i < str.Length; i++)
{
if (!list.Contains(str[i]))
list.Add(str[i]);
}
for(int i=0;i<list.Count;i++)
Console.WriteLine(list[i]);
}
解决方案 »
- 无题
- 程序正在运行。这时候修改 Web.config 后,所有Cache 全局变量会自动消失吗??
- sessionState的问题
- onClick=OpenDialog问题
- |M| throw new 问题
- 如何在asp.net中做个监控事件来监控session值,当session 值为空的时候自动跳转到登录页面!
- 这么一用到asp.net的Lalbe控件都有这样的提试。。
- 一个很简单的存储过程,TOP n 选择记录非的设置为常量么?
- 求助,可以再加分!
- 如何用DataGrid将模板列中的TextBox框中的内容一次性写入数据库中?分不够在加,解决问题者要多少都行?
- 管理网站出错
- 两个程序的连接!
ArrayList al = new ArrayList();
foreach (string ele in str)
{
if (!al.Contains(ele))
{
al.Add(ele);
}
} for (int i = 0; i < al.Count; i++)
{
Response.Write(al[i].ToString() + "<BR>");
}
string[] s = {"5","2","1","2" };
var ss = s.Distinct();
foreach (string sss in ss)
{
Response.Write(sss);
}