<?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: Automatic comparison operator overloading in C#</title>
	<atom:link href="http://damieng.com/blog/2005/10/11/automaticcomparisonoperatoroverloadingincsharp/feed" rel="self" type="application/rss+xml" />
	<link>http://damieng.com/blog/2005/10/11/automaticcomparisonoperatoroverloadingincsharp?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automaticcomparisonoperatoroverloadingincsharp</link>
	<description>A .NET developer in silicon valley</description>
	<lastBuildDate>Wed, 11 Apr 2012 18:41:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: bob r</title>
		<link>http://damieng.com/blog/2005/10/11/automaticcomparisonoperatoroverloadingincsharp#comment-42124</link>
		<dc:creator>bob r</dc:creator>
		<pubDate>Tue, 20 Jul 2010 00:01:10 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2005/10/11/automaticcomparisonoperatoroverloadingincsharp.aspx#comment-42124</guid>
		<description>Very nice.  Saves me quite a bit of typing.

A (very) minor issue:
&lt;pre&gt;&lt;code&gt;public override bool Equals(object obj) {
   if (!(obj is AutoOperators)) return false;
   return this == (AutoOperators) obj;
}&lt;/code&gt;&lt;/pre&gt;
Will cause &quot;Code Analysis&quot; (FxCop ??) to issue a 
&quot;Warning	1	CA1800 : Microsoft.Performance : &#039;obj&#039;, a parameter, is cast to type &#039;AutoOperators&#039; multiple times in method &#039;AutoOperators.Equals(object)&#039;. Cache the result of the &#039;as&#039; operator or direct cast in order to eliminate the redundant castclass instruction.	..\AutoOperators.cs	54&quot;

Changing it to:
&lt;pre&gt;&lt;code&gt;public override bool Equals(object obj) {
   AutoOperators other = obj as AutoOperators;
   return (other != null) ? (this == other) : false;
}&lt;/code&gt;&lt;/pre&gt;

makes the &quot;Code Analysis&quot; program happy.  The same issue arises in the &quot;CompareTo&quot; override.

The if/else structure does work better if the comparison requires more than a simple expression while the conditional operator is very concise if a simple expression will do the job.

Thanks,
Bob R</description>
		<content:encoded><![CDATA[<p>Very nice.  Saves me quite a bit of typing.</p>
<p>A (very) minor issue:</p>
<pre><code>public override bool Equals(object obj) {
   if (!(obj is AutoOperators)) return false;
   return this == (AutoOperators) obj;
}</code></pre>
<p>Will cause &#8220;Code Analysis&#8221; (FxCop ??) to issue a<br />
&#8220;Warning	1	CA1800 : Microsoft.Performance : &#8216;obj&#8217;, a parameter, is cast to type &#8216;AutoOperators&#8217; multiple times in method &#8216;AutoOperators.Equals(object)&#8217;. Cache the result of the &#8216;as&#8217; operator or direct cast in order to eliminate the redundant castclass instruction.	..\AutoOperators.cs	54&#8243;</p>
<p>Changing it to:</p>
<pre><code>public override bool Equals(object obj) {
   AutoOperators other = obj as AutoOperators;
   return (other != null) ? (this == other) : false;
}</code></pre>
<p>makes the &#8220;Code Analysis&#8221; program happy.  The same issue arises in the &#8220;CompareTo&#8221; override.</p>
<p>The if/else structure does work better if the comparison requires more than a simple expression while the conditional operator is very concise if a simple expression will do the job.</p>
<p>Thanks,<br />
Bob R</p>
]]></content:encoded>
	</item>
</channel>
</rss>

