title: Converting FieldInfo value to a List When List type not known
body: <p>I have the following:</p>
  
  <pre><code>    [Serializable()]
      public struct ModuleStruct {
          public string moduleId;
          public bool isActive;
          public bool hasFrenchVersion;
          public string titleEn;
          public string titleFr;
          public string descriptionEn;
          public string descriptionFr;
          public bool isLoaded;
          public List&lt;SectionStruct&gt; sections;
          public List&lt;QuestionStruct&gt; questions;
      }
  </code></pre>
  
  <p>I create an instance of this and populate it (contents not relevant for question). I have a function which takes the instantiated object as one parameter, lets call it module, and the type of this object as the other parameter: <code>module.GetType()</code>.</p>
  
  <p>This function will then, using reflection, and:</p>
  
  <pre><code>    FieldInfo[] fields = StructType.GetFields();
      string fieldName = string.Empty;
  </code></pre>
  
  <p>The parameter names in the function are <code>Struct</code> and <code>StructType</code>.</p>
  
  <p>I loop through the field names within <code>Struct</code>, pull the values and of the different fields and do something with it. All is well until I get to:</p>
  
  <pre><code>    public List&lt;SectionStruct&gt; sections;
      public List&lt;QuestionStruct&gt; questions;
  </code></pre>
  
  <p>The function only knows the type of <code>Struct</code> by <code>StructType</code>. In VB, the code is simply:</p>
  
  <pre><code>    Dim fieldValue = Nothing
      fieldValue = fields(8).GetValue(Struct)
  </code></pre>
  
  <p>and then:</p>
  
  <pre><code>    fieldValue(0)
  </code></pre>
  
  <p>to get the first element in the list sections; however, in C#, the same code does not work because <code>fieldValue</code> is an object and I cannot do <code>fieldValue[0]</code> on an object. </p>
  
  <p>My question, then, is given that the function only knows the type of <code>Struct</code> by <code>StructType</code>, how do I replicate the VB behaviour in C#, if it is even possible?</p>