I've a notepad file that has the following format:
[email protected]
[email protected]
[email protected]
[email protected]
I require the following distinct output:
[email protected]
[email protected]
Tried the following code but it doesn't get distinct values:
List<string> lst = new List<string>();
foreach (string line in File.ReadLines(values))
{
line.Distinct().ToString();
lst.Add(line);
}
I know, this may seem stupid and guessing, missed something here.
First you should read all the lines and then get the distinct lines:
var allLines = File.ReadLines(values);
var distinctLines = allLines.Distinct();
foreach(var distinctLine in distinctLines)
{
Console.WriteLine(distinctLine);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With