C#代码片段 导入一个txt文本,快速过滤重复行
c#导入一个txt文本,快速过滤重复行HashSet<string> strlist = new HashSet<string>();
if(openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK){
//
string filename = openFileDialog1.FileName;
int repcnt=0;
string[] lines = System.IO.File.ReadAllLines(filename,System.Text.Encoding.Default);
for(int i=0;i<lines.Length;i++){
if(lines[i]!=""){
if( !strlist.Add(lines[i])){
repcnt++;
}
}
}
if(repcnt>0){
SetLog("过滤重复 " + repcnt);
}
SetLog("导入数量 " + strlist.Count);
}
如果您需要定制c#桌面windows程序,可以联系:qq7477118
全站开发qq群交流见页面底部
跟多出重教程:
java海量数据下的去重和查重 海量数据BitMap位图法去重过滤





