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.3k Views Asked by Evildommer5 At
3
There are 3 best solutions below
0

Iterate through the file, save what you find in a collection, ignore already analyzed entries and in the end, just check the size of the collection.
0

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.