<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Why a comparison of a value type with null is a warning?</title><link>http://blogs.msdn.com/kirillosenkov/archive/2008/09/08/why-a-comparison-of-a-value-type-with-null-is-a-warning.aspx</link><description>A reader (Petar Petrov) asked me a question recently which I didn't quite know how to answer: Why a comparison of a value type against null is a warning? I definitely think it should be a compiler error. So I asked the C# compiler team and here's the</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Why a comparison of a value type with null is a warning?</title><link>http://blogs.msdn.com/kirillosenkov/archive/2008/09/08/why-a-comparison-of-a-value-type-with-null-is-a-warning.aspx#8937220</link><pubDate>Tue, 09 Sep 2008 21:46:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8937220</guid><dc:creator>ysweet</dc:creator><description>&lt;p&gt;if you have a generic with unconstrained T type parameter, it is really useful that C# allows comparison to null even if T can be value type. I even used default(T) == null as a test whether T is reference type. &lt;/p&gt;
</description></item><item><title>re: Why a comparison of a value type with null is a warning?</title><link>http://blogs.msdn.com/kirillosenkov/archive/2008/09/08/why-a-comparison-of-a-value-type-with-null-is-a-warning.aspx#8945578</link><pubDate>Fri, 12 Sep 2008 00:43:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8945578</guid><dc:creator>Kirill Osenkov</dc:creator><description>&lt;p&gt;That's a good point, by the way!&lt;/p&gt;
</description></item><item><title>re: Why a comparison of a value type with null is a warning?</title><link>http://blogs.msdn.com/kirillosenkov/archive/2008/09/08/why-a-comparison-of-a-value-type-with-null-is-a-warning.aspx#8964699</link><pubDate>Thu, 25 Sep 2008 10:31:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8964699</guid><dc:creator>madduck</dc:creator><description>&lt;p&gt;If we all did the right thing and compiled with warnings-as-errors, this point would be moot.&lt;/p&gt;
&lt;p&gt;Of course, generated code would probably want to compile without it.&lt;/p&gt;
</description></item><item><title>re: Why a comparison of a value type with null is a warning?</title><link>http://blogs.msdn.com/kirillosenkov/archive/2008/09/08/why-a-comparison-of-a-value-type-with-null-is-a-warning.aspx#9852203</link><pubDate>Wed, 29 Jul 2009 18:33:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9852203</guid><dc:creator>Lucas</dc:creator><description>&lt;p&gt;@ysweet Be careful with that check for reference type. For nullable types it will return true but they are still value types, not reference types.&lt;/p&gt;
</description></item></channel></rss>