title: C# How to convert an object with IList to IList<object>?
body: <p>I have an object which implements <code>IList</code> interface, I want to cast it to <code>IList&lt;object&gt;</code> or 
  <code>List&lt;object&gt;</code>, 
  I tried </p>
  
  <pre><code>IList&lt;object&gt; a=(IList&lt;object&gt;)b;
  List&lt;object&gt; a=(IList&lt;object&gt;)b;
  IList&lt;object&gt; a=(List&lt;object&gt;)b;
  List&lt;object&gt; a=(List&lt;object&gt;)b;
  </code></pre>
  
  <p>These are not working. Please help, thanks.
  To clarify:</p>
  
  <p>b is an object pass as parameter from outside. It implements IList interface. For example, </p>
  
  <pre><code>public class a
  {
    string name;
    List&lt;a&gt; names;
  }
  public void func(object item)
  {
    object dataLeaves = data.GetType().GetProperty("names").GetValue(dataInput, null);
    if (dataLeaves != null &amp;&amp; dataLeaves.GetType().GetInterfaces().Any(t =&gt;t.IsGenericType &amp;&amp; t.GetGenericTypeDefinition() == typeof(IList&lt;&gt;)))
    {
      List&lt;object&gt; a=(List&lt;object&gt;) dataLeaves; //Need to convert the dataLeaves to list or IList
    }
  }
  </code></pre>