<?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>Here there be tigers - operator overloading and conversions</title><link>http://blogs.msdn.com/b/ericgu/archive/2003/12/12/43208.aspx</link><description>I came across a discussion in the last few days that I thought I would share with you. It concerns the following code: 
 class Utility { public void Process(object o); public void Process(string s); } 
 and then a call to Process that passed in a string</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>MBA</title><link>http://blogs.msdn.com/b/ericgu/archive/2003/12/12/43208.aspx#324597</link><pubDate>Sat, 18 Dec 2004 18:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:324597</guid><dc:creator>MBA</dc:creator><description>Helpful For MBA Fans.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=324597" width="1" height="1"&gt;</description></item><item><title>re: Here there be tigers - operator overloading and conversions</title><link>http://blogs.msdn.com/b/ericgu/archive/2003/12/12/43208.aspx#45115</link><pubDate>Mon, 22 Dec 2003 13:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:45115</guid><dc:creator>Keith</dc:creator><description>Joe,&lt;br&gt;You need to cast the null to either Object or String (I have a couple of cases in some uses of String.Format where I have this problem in addition to having to do it sometimes when using ? : notation.  Well, it's not really a problem, since it is a very rare case for me that is an error not a warning, so I've never had an issue knowing which was going to be executed)&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=45115" width="1" height="1"&gt;</description></item><item><title>re: Here there be tigers - operator overloading and conversions</title><link>http://blogs.msdn.com/b/ericgu/archive/2003/12/12/43208.aspx#43914</link><pubDate>Tue, 16 Dec 2003 20:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:43914</guid><dc:creator>Eric</dc:creator><description>Joe,&lt;br&gt;&lt;br&gt;I think that case falls out from the rules. There's an implicit conversion from null to object, and to string (by the reference conversion rules). &lt;br&gt;&lt;br&gt;There's an implicit conversion from string to object, but not from object to string, so Process(string s) is better. &lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=43914" width="1" height="1"&gt;</description></item><item><title>re: Here there be tigers - operator overloading and conversions</title><link>http://blogs.msdn.com/b/ericgu/archive/2003/12/12/43208.aspx#43905</link><pubDate>Tue, 16 Dec 2003 20:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:43905</guid><dc:creator>Joe McRay</dc:creator><description>Hi Eric!&lt;br&gt;&lt;br&gt;class Utility&lt;br&gt;{&lt;br&gt;    public void Process(object o);&lt;br&gt;    public void Process(string s);&lt;br&gt;}&lt;br&gt;&lt;br&gt;And what about&lt;br&gt;Utility.Process(null);&lt;br&gt;?&lt;br&gt;&lt;br&gt;How does the compiler decide in this situation?&lt;br&gt;I think/know there must be rules, nevertheless I couldn't find any topic in the MSDN Lib (7.4.2.2). Maybe you can give me a hint.&lt;br&gt;&lt;br&gt;Thx. Joe.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=43905" width="1" height="1"&gt;</description></item><item><title>re: Here there be tigers - operator overloading and conversions</title><link>http://blogs.msdn.com/b/ericgu/archive/2003/12/12/43208.aspx#43242</link><pubDate>Fri, 12 Dec 2003 22:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:43242</guid><dc:creator>CausticMango</dc:creator><description>Hmm, good point. However, I'd have to question the intent for such an ambiguous overloading to begin with. It may be legitimate (aka a visitor implementation), but it's definitely suspicious.&lt;br&gt;&lt;br&gt;There may be better ways to skin that cat (such as using the template method pattern and avoiding the ambiguous overload).&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=43242" width="1" height="1"&gt;</description></item></channel></rss>