http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=185743
解决方案 »
- UDP ,开线程接受,线程只接受一次,咋回事?
- 怎样根据IP获取对应的网关,并用字符串读取出来?
- C# WINFORM窗体之间传值丢失
- 关于指定图片文字水印的位置和获取水印宽高的问题
- winfrom程序向javascript中传递json 显示数据类型未定义undefined
- 高手来帮忙
- C#树问题
- 求一条Update触发器
- Winform treeView如何在指定的子节点添加节点?
- C#启动外部窗体(如excel)并嵌入主程序窗体
- 我的RichTextBox怎么不能写入任何文字,顶者有分
- 我在panel里放了一个picturebox,如何在picturebox里画矩形,而移动滚动条时矩形还能显示????
优化一下的话,可以先对数组排序再拷
也可以利用hashtable
public void test(string[] strArray)
{
HashTable hashtable=new HashTable();
foreach(string str in strArray)
{
//因为在hashtable里如果存在相同的键,就会抛异常,这时把这个异常屏掉就可以了
try{hashtable.Add(str,str);}catch{}
}
//这样hashtable.Keys里就不没有重复的字符串了
}
string[] s1 = {"1","2","4","4"}
Hashtable ht = new Hashtable();
foreach(string s in s1)
{
try
{
ht.Add(s, "");
}
catch{}
}
Hashtable htb = new Hashtable();
for(int i = 0; i< str.Length; i++)
{
if(!htb.ContainsValue(str[i]))
{
htb.Add(i,str[i]);
Console.Write(str[i]);
}
}