<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.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>C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx</link><description>I&amp;#39;ve not played with the VS2010 CTP much yet, and I&amp;#39;ve only looked briefly at the documentation and blogs about the new C# 4.0 dynamic type, but a thought occurred to me: why not have the option of making it generic as a way of saying &amp;quot;I</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1666810</link><pubDate>Thu, 29 Jan 2009 05:01:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1666810</guid><dc:creator>MiddleTommy</dc:creator><description>&lt;p&gt;I have thought this would be the first &amp;quot;dynamic&amp;quot; step c# would go in but I guess they are trying to target python type dynamic users rather that give c#ers what dynamics they want.&lt;/p&gt;
&lt;p&gt;I thought you should declare it like this&lt;/p&gt;
&lt;p&gt;public dynamic interface IMessageRouter&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;void Send(string message, string destination);&lt;/p&gt;
&lt;p&gt;} &lt;/p&gt;
&lt;p&gt;and then use it as a normal interface with &amp;quot;is&amp;quot; and &amp;quot;as&amp;quot; keywords but no type ever needs to derive from it. and if the dynamic interface doesnt match it is just null. Easy to handle and easy to learn. &lt;/p&gt;
&lt;p&gt;Thats my two cents on Duck Typing in C#&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1666810" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1656136</link><pubDate>Mon, 08 Dec 2008 05:55:57 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1656136</guid><dc:creator>Mehrdad Afshari</dc:creator><description>&lt;p&gt;Yeah, I understand that you didn&amp;#39;t suggest it as the only method for dynamic method dispatch. And I agree we&amp;#39;re all just guessing, but this is how designs work, isn&amp;#39;t it? Nobody knows what&amp;#39;s going happen in the future.&lt;/p&gt;
&lt;p&gt;To clarify what I meant from false sense of safety, it&amp;#39;s really mostly the Intellisense thing. If something shows up in Intellisense, I&amp;#39;ll pretty much believe that it do exist. The specially negative point is, in my opinion, the fact that you might have a couple methods in your interface, one of them exists in the type, the other doesn&amp;#39;t exist. You&amp;#39;ll start debugging, you see it&amp;#39;s successfully cast to dynamic&amp;lt;MyInterface&amp;gt; since you can call it&amp;#39;s First() method successfully, but it fails on the Second() method call. I think such a suggestion should only be implemented if member existence is checked at the time of assignment (which is a performance hit). &lt;/p&gt;
&lt;p&gt;Another thing is, C# is not going to be a dynamic language. I think C# developers should stick to static typing as much as possible and use dynamic types when it really helps. I&amp;#39;ll see two situations where dynamic typing is specifically useful, first is COM interop, which usually have much more clutter that you&amp;#39;re able to define interfaces for easily (unless the code is generated by a tool) and they have a lot of pretty useless parameters (for which named parameters exist). The other case which dynamic typing is very useful is interfacing with dynamic languages and dynamic environments. Some dynamic languages support dynamically adding and removing methods at runtime, and I don&amp;#39;t think your idea is suited for them either. After all, if you know enough about the object and use it more than a couple of times in your code (to make it worth declare the interface), static typing is probably the way to go. This feature might unnecessarily make people go for dynamic typing, which C# designers are probably going to avoid.&lt;/p&gt;
&lt;p&gt;I personally think Intellisense is and should be the smartness of the IDE, not the language. I should not manually hint VS to show intellisense for me. If this is merely to help VS, I think it&amp;#39;s better be a special type of comment rather than a syntactic thing that compiler understands. VS should be designed to support C# well, not the other way around.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s just my personal opinion. I&amp;#39;m not a language designer and you probably have a lot more experience in this area.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1656136" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1656087</link><pubDate>Sun, 07 Dec 2008 20:04:52 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1656087</guid><dc:creator>skeet</dc:creator><description>&lt;p&gt;@Mehrdad: With dynamic&amp;lt;IFoo&amp;gt; you&amp;#39;d get Intellisense, and avoid typos which would otherwise only be discovered at execution time. How does that harm productivity?&lt;/p&gt;
&lt;p&gt;Note that I&amp;#39;m not suggesting this would be the *only* type of dynamic dispatch - I&amp;#39;d suggest keeping the &amp;quot;raw&amp;quot; dynamic type as well. If people didn&amp;#39;t find it helped them to be productive, they could just use the raw form.&lt;/p&gt;
&lt;p&gt;As for giving a false sense of safety - the word &amp;quot;dynamic&amp;quot; is still pretty prominent. If that&amp;#39;s not enough of a hint, I don&amp;#39;t know what is :(&lt;/p&gt;
&lt;p&gt;Unfortunately it&amp;#39;s unlikely that we&amp;#39;ll ever be able to see how useful or otherwise it would be - which means both of us are guessing, basically :(&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1656087" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1656085</link><pubDate>Sun, 07 Dec 2008 19:54:28 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1656085</guid><dc:creator>Mehrdad Afshari</dc:creator><description>&lt;p&gt;I think the dynamic type is there primarily to improve productivity while working with extremely dynamic environment. If you&amp;#39;re working in such an environment, it would take a long time to implement these kind of interfaces. I think your idea is very similar to Java&amp;#39;s checked exceptions (which C# designers don&amp;#39;t like). It will harm productivity without adding significant benefits.&lt;/p&gt;
&lt;p&gt;In addition, it makes false sense of safety. Your code might compile OK and you&amp;#39;ll think it&amp;#39;s not going to fail (since, in C#, you&amp;#39;re used to strong type checks at compile time) while at run time, it&amp;#39;ll throw an exception due to an unresolved method. But when you declare it as &amp;quot;dynamic&amp;quot; alone, you are basically NOT expecting the compiler to do anything for you and you say you&amp;#39;re aware of what you are doing.&lt;/p&gt;
&lt;p&gt;Your idea is very cool in isolation, but considering C# language style, I think it doesn&amp;#39;t fit very well.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1656085" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1655083</link><pubDate>Wed, 26 Nov 2008 02:30:10 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1655083</guid><dc:creator>Bart</dc:creator><description>&lt;p&gt;FYI, a while ago I posted about the idea of a &amp;quot;ducktaper&amp;quot; which is essentially a runtime-generated wrapper object. As Curt comes to say such a wrapper suffers from an identity crisis (you could go off and think of ways to band-aid restore identity to the Equals method extent as you&amp;#39;re controlling the wrapper anyway, but let&amp;#39;s leave that discussion for another time) amongst other defects like piggybacking on interfaces for not-so-good reasons and limitations/caveats from LCG in general.&lt;/p&gt;
&lt;p&gt;More info at &lt;a rel="nofollow" target="_new" href="http://community.bartdesmet.net/blogs/bart/archive/2008/11/10/introducing-the-c-ducktaper-bridging-the-dynamic-world-with-the-static-world.aspx"&gt;community.bartdesmet.net/.../introducing-the-c-ducktaper-bridging-the-dynamic-world-with-the-static-world.aspx&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;-Bart&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1655083" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1654418</link><pubDate>Tue, 18 Nov 2008 06:24:25 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1654418</guid><dc:creator>skeet</dc:creator><description>&lt;p&gt;I&amp;#39;m suggesting that for the purposes of Intellisense and *static* compilation, dynamic&amp;lt;T&amp;gt; would only expose the members of T. In other words, you could have:&lt;/p&gt;
&lt;p&gt;dynamic&amp;lt;IDispose&amp;gt; foo = GetSomeObject();&lt;/p&gt;
&lt;p&gt;foo.Dispose(); // Legal&lt;/p&gt;
&lt;p&gt;foo.RandomMethod(); // Not legal&lt;/p&gt;
&lt;p&gt;However, the actual binding would still be done at execution time - so GetSomeObject() could return something which had a Dispose method, but didn&amp;#39;t know it was implementing IDisposable.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1654418" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1654396</link><pubDate>Tue, 18 Nov 2008 01:51:36 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1654396</guid><dc:creator>Curt Hagenlocher</dc:creator><description>&lt;p&gt;Ah, so you&amp;#39;re not suggesting that dynamic&amp;lt;T&amp;gt; actually implement T. &amp;nbsp;If that&amp;#39;s the case, then I don&amp;#39;t think I understand what this would gain you.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1654396" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1653588</link><pubDate>Sun, 09 Nov 2008 18:17:10 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1653588</guid><dc:creator>skeet</dc:creator><description>&lt;p&gt;Curt: Were you suggesting that my idea requires the creation of a wrapper object? It certainly wouldn&amp;#39;t. It would be a dynamic object in the normal way, just with the compiler reducing the amount of operations available.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1653588" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1653573</link><pubDate>Sun, 09 Nov 2008 12:20:37 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1653573</guid><dc:creator>Curt Hagenlocher</dc:creator><description>&lt;p&gt;One problem with this idea is that it requires creation of a wrapper object. &amp;nbsp;There are lots of potential gotchas when object identity isn&amp;#39;t maintained.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1653573" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652951</link><pubDate>Mon, 03 Nov 2008 20:04:05 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652951</guid><dc:creator>Tobi</dc:creator><description>&lt;p&gt;Hey Jon,&lt;/p&gt;
&lt;p&gt;inspired by your post I wrote about IDynamicObject - and I think I did make it possible to have the kind of conversion Jesper asked for in the first comment. Go check it out: &lt;a rel="nofollow" target="_new" href="http://saftsack.fs.uni-bayreuth.de/~dun3/archives/first-look-ducktyping-c-4-0-idynamicobject-metaobject/202.html"&gt;saftsack.fs.uni-bayreuth.de/.../202.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cheers and keep up the great work!&lt;/p&gt;
&lt;p&gt;Tobi&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652951" width="1" height="1"&gt;</description></item><item><title>Tobi + C# = T# &amp;raquo; A first look at Duck Typing in C# 4.0</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652943</link><pubDate>Mon, 03 Nov 2008 19:21:16 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652943</guid><dc:creator>Tobi + C# = T# » A first look at Duck Typing in C# 4.0</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Tobi + C# = T# &amp;raquo; A first look at Duck Typing in C# 4.0&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652943" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652840</link><pubDate>Sun, 02 Nov 2008 20:52:54 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652840</guid><dc:creator>Omer van Kloeten</dc:creator><description>&lt;p&gt;It&amp;#39;s funny how this came to my mind as well[1]. Unfortunately, I couldn&amp;#39;t find many supporters for this either, including David who commented about your post as well.&lt;/p&gt;
&lt;p&gt;[1] &lt;a rel="nofollow" target="_new" href="http://weblogs.asp.net/okloeten/archive/2008/10/29/6708812.aspx"&gt;weblogs.asp.net/.../6708812.aspx&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652840" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652712</link><pubDate>Fri, 31 Oct 2008 21:48:29 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652712</guid><dc:creator>James Hart</dc:creator><description>&lt;p&gt;I was trying to think of a way to do ducktyping to interfaces now we have dynamic; Agreed - this approach as a language feature would be nice. My best effort would be:&lt;/p&gt;
&lt;p&gt;public class DynamicMessageRouter : IMessageRouter&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;private dynamic _d;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public DynamicMessageRouter(dynamic d)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;_d = d;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public void Send(string message, string destination)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_d.Send(message, destination);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Simple enough as a pattern to be codegenned for a given interface, but it&amp;#39;d be nice to have this class available automatically for every interface, without having to code it. Maybe a virtual &amp;quot;inner type&amp;quot; of the interface - IMessageRouter.dynamic ?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652712" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652703</link><pubDate>Fri, 31 Oct 2008 20:53:11 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652703</guid><dc:creator>Charles Feduke</dc:creator><description>&lt;p&gt;We&amp;#39;re *almost* to the point of Objective-C&amp;#39;s objc_msgSend(), I think we just need a built in message forwarding mechanism -before- the exception throwing piece is allowed to throw an exception and we&amp;#39;ll be set.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652703" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652685</link><pubDate>Fri, 31 Oct 2008 19:25:50 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652685</guid><dc:creator>Keith J. Farmer</dc:creator><description>&lt;p&gt;@David: &amp;nbsp;Static typing hasn&amp;#39;t been &amp;quot;tossed out the window&amp;quot;. &amp;nbsp;What has been &amp;quot;tossed out the window&amp;quot; has been a tremendous amount of reflection pain. &amp;nbsp;The reason that pain exists is because there are things -- valuable things that underpin frameworks you almost certainly use -- that static typing cannot cope with. &amp;nbsp;The dynamic support addresses part of the pain.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652685" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652666</link><pubDate>Fri, 31 Oct 2008 15:53:44 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652666</guid><dc:creator>David Nelson</dc:creator><description>&lt;p&gt;A number of people have been blogging about this. Personally I think it would have been a far better way to go than what has been announced. Unfortunately, in many dynamic languages, members can be added and removed from objects at runtime. So querying an object for its members at a specific point in time would be a significant limitation. However, in my opinion, accepting that limitation would still be far better for the C# language than tossing static typing out the window, which is what the C# team has apparently settled on.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652666" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652633</link><pubDate>Fri, 31 Oct 2008 11:06:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652633</guid><dc:creator>Petar Repac</dc:creator><description>&lt;p&gt;This could drive developers in creating interfaces that are really never implemented, so they get intellisense and compile time checking. Is this acceptable ?&lt;/p&gt;
&lt;p&gt;What if we get refactoring tool that could create a wrapper around dynamic object based on some inteface. Then we could remove methods we know we will not use or our dynamic object doesn&amp;#39;t have. &lt;/p&gt;
&lt;p&gt;Other idea would be C# syntactic sugar that creates this wrapper for us. Something like delegate keyword that creates class that derives from MulticastDelegate.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652633" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652629</link><pubDate>Fri, 31 Oct 2008 09:51:51 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652629</guid><dc:creator>skeet</dc:creator><description>&lt;p&gt;Mike: This would basically be duck casting, but making it really obvious that you&amp;#39;re *expecting* duck casting instead of normal static casting. I&amp;#39;d want to keep the two very separate - C# is still a statically typed language at heart :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652629" width="1" height="1"&gt;</description></item><item><title>re: C# 4.0: dynamic&lt;T&gt; ?</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652628</link><pubDate>Fri, 31 Oct 2008 09:42:54 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652628</guid><dc:creator>Mike Hadlow</dc:creator><description>&lt;p&gt;Jon, why not just have &amp;#39;duck casting&amp;#39;. If the dynamic object provides the methods/properties defined in the interface it can be cast to that interface.&lt;/p&gt;
&lt;p&gt;Right now, this doesn&amp;#39;t work:&lt;/p&gt;
&lt;p&gt;dynamic realRouter = new MessageRouter(); // MessageRouter doesn&amp;#39;t implement IMessageRouter&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// but does have a send(string,string) method.&lt;/p&gt;
&lt;p&gt;IMessageRouter router = realRouter; &amp;nbsp; &amp;nbsp; &amp;nbsp; // compiles, but InvalidCastException is thrown when run&lt;/p&gt;
&lt;p&gt;But it would be cool if it did.&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652628" width="1" height="1"&gt;</description></item><item><title>C# 4.0: dynamic</title><link>http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx#1652627</link><pubDate>Fri, 31 Oct 2008 09:29:07 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652627</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You&amp;#39;ve been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652627" width="1" height="1"&gt;</description></item></channel></rss>