当前位置:编程学习 > C/C++ >>

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位图法去重过滤

C#代码片段 导入一个txt文本,快速过滤重复行

php读取txt文件然后去重内容

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,