<?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>Performance of IConvertible operations: which operation is fastest? [Kit George]</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx</link><description>I saw this question recently: " Double d = (( IConvertible ) o).ToDouble( System.Threading. Thread .CurrentThread.CurrentCulture) ; Is this the best way (speed, correctness) to convert a boxed instance of one primitive types below to a double?" I thought</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> BCL Team Blog Performance of IConvertible operations which operation | debt settlement program</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx#9787411</link><pubDate>Fri, 19 Jun 2009 16:29:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9787411</guid><dc:creator> BCL Team Blog Performance of IConvertible operations which operation | debt settlement program</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://edebtsettlementprogram.info/story.php?id=22760"&gt;http://edebtsettlementprogram.info/story.php?id=22760&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9787411" width="1" height="1"&gt;</description></item><item><title>Converting between Object and Classes that inherit object | keyongtech</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx#9364436</link><pubDate>Thu, 22 Jan 2009 10:50:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9364436</guid><dc:creator>Converting between Object and Classes that inherit object | keyongtech</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.keyongtech.com/463230-converting-between-object-and-classes"&gt;http://www.keyongtech.com/463230-converting-between-object-and-classes&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9364436" width="1" height="1"&gt;</description></item><item><title>re: Performance of IConvertible operations: which operation is fastest? [Kit George]</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx#377064</link><pubDate>Mon, 21 Feb 2005 02:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:377064</guid><dc:creator>zzz</dc:creator><description>Whoa, what machine is that?&lt;br&gt;I get (release build and not started from vs)&lt;br&gt;&lt;br&gt;double cast               4159976-5958480&lt;br&gt;IConvertible.ToDouble    91323260&lt;br&gt;Double.ToDouble          48208260&lt;br&gt;Convert.ToDouble         46969660&lt;br&gt;Double.Parse           2269345148&lt;br&gt;&lt;br&gt;With 3 Ghz P4+HT&lt;br&gt;&lt;br&gt;Quite a big fluctuation on that double cast here. I have the December ctp..&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=377064" width="1" height="1"&gt;</description></item><item><title>re: Performance of IConvertible operations: which operation is fastest? [Kit George]</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx#373386</link><pubDate>Tue, 15 Feb 2005 23:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:373386</guid><dc:creator>Daniel Moth</dc:creator><description>Just FYI, I run the same tests against Compact Framework 1.0 and with VB.NET&lt;br&gt;&lt;br&gt;Like here casting is the clear winner. DirectCast that is; CType or CDbl are equally slower than Convert.ToDouble which itself trails IConvertible.ToDouble. &lt;br&gt;Note that for the IConvertibleToDouble case I passed in System.Globalization.CultureInfo.CurrentCulture (as the Threading culture is unavailable on CF).&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=373386" width="1" height="1"&gt;</description></item><item><title>re: Performance of IConvertible operations: which operation is fastest? [Kit George]</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx#372446</link><pubDate>Mon, 14 Feb 2005 21:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:372446</guid><dc:creator>Joe White</dc:creator><description>I don't know about Whidbey, but in the 1.1 Framework, Convert.ToDouble(object value) looks like it just casts its argument to IConvertible and calls ToDouble on it.&lt;br&gt;&lt;br&gt;The only thing I see that would make Convert.ToDouble any faster than your explicit IConvertible call is that Convert.ToDouble passes null for the IFormatProvider, instead of passing System.Threading.Thread.CurrentThread.CurrentCulture.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=372446" width="1" height="1"&gt;</description></item><item><title>re: Performance of IConvertible operations: which operation is fastest? [Kit George]</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx#372063</link><pubDate>Mon, 14 Feb 2005 04:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:372063</guid><dc:creator>Kent Boogaart</dc:creator><description>As Matt said, your Double.ToDouble() example is actually invoking Convert.ToDouble(). Hopefully you just posted the wrong code?&lt;br&gt;&lt;br&gt;As for Double.ToDouble(), it is explicitly implemented so you'd have to invoke it like this:&lt;br&gt;&lt;br&gt;Double d = ((IConvertible) o).ToDouble();&lt;br&gt;&lt;br&gt;Kent&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=372063" width="1" height="1"&gt;</description></item><item><title>re: Performance of IConvertible operations: which operation is fastest? [Kit George]</title><link>http://blogs.msdn.com/b/bclteam/archive/2005/02/11/371436.aspx#371523</link><pubDate>Sat, 12 Feb 2005 08:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:371523</guid><dc:creator>Matthew W. Jackson</dc:creator><description>I'm obviously missing something here.&lt;br&gt;&lt;br&gt;First of all...Double.ToDouble()?  Is this new in Whidbey beta 2?  I'm certainly not finding it in beta 1.  Because in my copy, Convert.ToDouble(object) is just as bad as calling through IConvertible (in fact, that's what it appears to do).  If this is beta 2 (or even if it's Whidbey in general, which it obviously is due to StopWatch), it would be nice for you to start out by mentioning that.  People not playing around with the beta right now may be even more confused than I.&lt;br&gt;&lt;br&gt;Second of all...Your example for Double.ToDouble is calling Convert.ToDouble() and not Double.ToDouble().&lt;br&gt;&lt;br&gt;But aside from that, if what you say is true, them I'm glad to see some performance improvements on converting a boxed object.  This will automatically help improve all ADO.NET code, since Data Readers methods all seem to always call Convert.ToXXX().  I assume it will also help VB non-Option-Strict code as well (although I'm not to familiar with how it is implemented under the hood).&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=371523" width="1" height="1"&gt;</description></item></channel></rss>