<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Remove Duplicate Lines From A Text File Using LINQ</title>
	<atom:link href="http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/</link>
	<description>a learning effort by Deepak Kapoor</description>
	<lastBuildDate>Thu, 09 Feb 2012 13:29:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Rob</title>
		<link>http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/comment-page-1/#comment-35254</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Wed, 08 Sep 2010 19:14:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/#comment-35254</guid>
		<description>Bah, it occurs to me that GetHashCode should probably be implemented as a.Substring(a.LastIndexOf(&#039;,&#039;) + 1).GetHashCode() - but I&#039;m sure you get the point.  Cheers!</description>
		<content:encoded><![CDATA[<p>Bah, it occurs to me that GetHashCode should probably be implemented as a.Substring(a.LastIndexOf(&#8216;,&#8217;) + 1).GetHashCode() &#8211; but I&#8217;m sure you get the point.  Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/comment-page-1/#comment-35253</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Wed, 08 Sep 2010 19:12:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/#comment-35253</guid>
		<description>For simply duplicate lines, you could easily do:

File.WriteAllLines(path, File.ReadAllLines(path).Distinct());

For your problem, I&#039;d suggest that a simpler method might be available, since you&#039;re already creating another class:
public class ErrorEqualityComparer : IEqualityComparer {
    public bool Equals(string a, string b) {
        return a.Substring(a.LastIndexOf(&#039;,&#039;) + 1) == b.Substring(b.LastIndexOf(&#039;,&#039;));
    }
    public int GetHashCode(string a) { return a.GetHashCode(); }
}

Now I can call:
File.WriteAllLines(path, File.ReadAllLines(path).Reverse().Distinct(new ErrorEqualityComparer()).Reverse());

This is certainly less LINQ-y, but it makes convenient use of extension methods.  :)

Thanks for the blog - helped me find an answer I needed for master/detail data.</description>
		<content:encoded><![CDATA[<p>For simply duplicate lines, you could easily do:</p>
<p>File.WriteAllLines(path, File.ReadAllLines(path).Distinct());</p>
<p>For your problem, I&#8217;d suggest that a simpler method might be available, since you&#8217;re already creating another class:<br />
public class ErrorEqualityComparer : IEqualityComparer {<br />
    public bool Equals(string a, string b) {<br />
        return a.Substring(a.LastIndexOf(&#8216;,&#8217;) + 1) == b.Substring(b.LastIndexOf(&#8216;,&#8217;));<br />
    }<br />
    public int GetHashCode(string a) { return a.GetHashCode(); }<br />
}</p>
<p>Now I can call:<br />
File.WriteAllLines(path, File.ReadAllLines(path).Reverse().Distinct(new ErrorEqualityComparer()).Reverse());</p>
<p>This is certainly less LINQ-y, but it makes convenient use of extension methods.  :)</p>
<p>Thanks for the blog &#8211; helped me find an answer I needed for master/detail data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liran</title>
		<link>http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/comment-page-1/#comment-769</link>
		<dc:creator>Liran</dc:creator>
		<pubDate>Sat, 27 Dec 2008 21:24:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.thereforesystems.com/remove-duplicate-lines-from-a-text-file-using-linq/#comment-769</guid>
		<description>in the method ReadFileIntoCollection, whats the point by doing
var query = from e in (linq the retrievs collection) select e ?

couldn&#039;t you just do it like this:
var query = linq the retrievs collection
?

Thank you.</description>
		<content:encoded><![CDATA[<p>in the method ReadFileIntoCollection, whats the point by doing<br />
var query = from e in (linq the retrievs collection) select e ?</p>
<p>couldn&#8217;t you just do it like this:<br />
var query = linq the retrievs collection<br />
?</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

