title: vb.net Cannot convert Dictionary(Of String, List(Of String)) to Object
body: <p>I have a web service in vb.net which returns json-formatted data.  One of the data items can take a number of different types of values: <code>Boolean</code>, <code>String</code>, <code>Dictionary(of String, String)</code> or <code>Dictionary(Of String, Object)</code>  The latter is to allow flexible lists of data to be returned.  Each then has an itemType and DataType specified in the response so the thirtd party knows what to expect.  This has worked fine.</p>
  
  <p>However, I am now getting the following error trying to return a <code>Dictionary(Of String, Dictionary(Of String, List(Of String)))</code>:</p>
  
  <pre><code>Value of type 'System.Collections.Generic.Dictionary(Of String, System.Collections.Generic.Dictionary(Of String, System.Collections.Generic.List(Of String)))' cannot be converted to 'System.Collections.Generic.Dictionary(Of String, Object)'.
  </code></pre>
  
  <p>It is quite happen to take a <code>Dictionary(Of String, Dictionary(Of String, String))</code> but not a <code>Dictionary(Of String, Dictionary(Of String, List(Of String)))</code>.  I am very confused -  I though pretty much anything could convert to <code>Object</code>?  Why can a <code>Dictionary(Of String, String)</code> convert to oject but not a <code>Dictionary(Of String, List(Of String))</code>?</p>
  
  <p>I can get round it by doing the following:</p>
  
  <pre><code>Dim Bar As New Dictionary(Of String, Dictionary(Of String, List(Of String)))
  ' Add stuff to bar here
  
  Dim Foo As New Dictionary(Of String, Object)
  For Each Row As KeyValuePair(Of String, Dictionary(Of String, List(Of String))) In Bar
      Foo.Add(Row.Key, New Dictionary(Of String, Object))
      For Each Item As KeyValuePair(Of String, List(Of String)) In Row.Value
          Foo(Row.Key).add(Item.Key, Item.Value)
      Next
  Next
  </code></pre>
  
  <p>but I don't understand why I need to.  is there something I am missing that could cause a problem later and can anyone explain what sorts of objects cannot be cast to <code>Object</code>?</p>