I have a txt document which has over 14000 different lines many of these are duplicates, is it possible to count the number of unique entries?
Count number of individual lines from a txt file c#
1.4k views Asked by Evildommer5 At
3
There are 3 answers
0
On
You can use the File.ReadLines Method and LINQ's Distinct and Count Extension Methods:
var result = File.ReadLines("input.txt").Distinct().Count();
It's a simply "One-Liner" like that:
Edit: But take care with those kind of solutions. With files larger than 600 MB you might get problems.