{"id":4742,"date":"2014-03-30T15:02:47","date_gmt":"2014-03-30T15:02:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/vb-net-does-not-throw-compiler-error-when-setting-dictionary-to-ilist-collection-of-common-programming-errors\/"},"modified":"2014-03-30T15:02:47","modified_gmt":"2014-03-30T15:02:47","slug":"vb-net-does-not-throw-compiler-error-when-setting-dictionary-to-ilist-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/vb-net-does-not-throw-compiler-error-when-setting-dictionary-to-ilist-collection-of-common-programming-errors\/","title":{"rendered":"VB.Net does not throw compiler error when setting Dictionary to IList-Collection of common programming errors"},"content":{"rendered":"<p>I am updating a legacy application, and it was reading a dll from another project for a Dictionary(of Guid, String) of items and using them.<\/p>\n<p>The requirements have changed, and the method that was returning the Dictionary is now returning an IList.<\/p>\n<p>This is the odd behavior of this; the intellisense is not throwing a cast error, nor is the compiler. It does not throw an error until runtime when it tries to set the Dictionary to the IList.<\/p>\n<p>Example:<\/p>\n<pre><code>        Dim someDictionary As Dictionary(Of Integer, String) = New Dictionary(Of Integer, String)\n        Dim someList As IList(Of Integer)\n        someDictionary = someList\n<\/code><\/pre>\n<p>Any idea as to why the compiler is not catching this?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am updating a legacy application, and it was reading a dll from another project for a Dictionary(of Guid, String) of items and using them. The requirements have changed, and the method that was returning the Dictionary is now returning an IList. This is the odd behavior of this; the intellisense is not throwing a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4742","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4742"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4742\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}