如果不要重复的id的话可以用hashset阿,自动过滤重复数据的
解决方案 »
- 实用的查询需求,这样的SQL 语句怎么写?
- 如何在C#下面实现简单的写Log文件功能?
- 网上下了个P2P聊天程序,用的时候出了些问题,请大家指教
- 如何在程序中设置一个下拉框中内容改变的事件?
- 调用非托管DLL中的函数后DataGrid的OnPaint方法系统报"溢出错误。"
- 一个关于时间比较的问题??
- 简体与繁体系统中界面错位问题
- End of Stream encountered before parsing was completed.
- 【【又来狂甩分了】】大家教教我WinForm下的ReportViewer到底是怎么用的啊【200分,帮顶有喜哈】
- C# Vs Delphi
- 急:请问啥高清压缩编码效率高?
- 怎么通过链接读取其内容?
using System.Collections;
using System.Text;using System.Text.RegularExpressions;namespace text
{
class test
{
private const string source = "267|266|265|264|263|262|261|260|259|258|257|256|255|254|253|252";
private const string remove = "256|262";
private const string add = "241|242|243|244|245|246|247|248|249|250|251|252|253|254|255|256|257|258|259";
static void Main()
{
Hashtable htable = new Hashtable();
if (getarr(source) != null && getarr(source).Length > 0)
{
foreach (string s in getarr(source))
{
htable.Add(s, "value:" + s);
}
}
if (getarr(remove) != null && getarr(remove).Length > 0)
{
foreach (string s in getarr(remove))
{
if (htable.ContainsKey(s))
htable.Remove(s);
}
}
if (getarr(add) != null && getarr(add).Length > 0)
{
foreach (string s in getarr(add))
{
if (!htable.ContainsKey(s))
htable.Add(s, "value:" + s);
}
}
foreach (DictionaryEntry d in htable)
{
Console.WriteLine(d.Key + " " + d.Value);
}
Console.ReadKey();
}
private static string[] getarr(string line)
{
if (line != null)
{
return line.Trim().Split(new char[1] { '|' });
}
return null;
}
}
}