title: Generic method for dictionary Object with variable values and loop through it
body: <p>I need to convert all my dictionary objects that coming from an api which are stored in results(model) to StudentList  type.</p>
  
  <p>I am doing it for one property as shown below:</p>
  
  <pre class="lang-cs prettyprint-override"><code>StudentList&lt;StudentData&gt; testList = new StudentList&lt;StudentData&gt;();
  
  foreach(KeyValuePair&lt;string, IEnumerable&lt;StudentData&gt;&gt; pair in result.StudentDataDetails)
  {
      foreach(var x in pair.Value)
          testList.Add(x);
  }
  </code></pre>
  
  <p>Like StudentData , there are other class objects like TeacherData, ParentData.. all these need to changed to  <code>StudentList&lt;TeacherData&gt;, StudentList&lt;ParentData&gt;</code>.</p>
  
  <p>I am trying to build a generic method for this..any help would be appreciated.  I need to check if there is a dictionary property from results in the following way <code>Dictionary&lt;string, IEnumerable&lt;T&gt;&gt;</code> then change the dictionary as mentioned above. T is StudentData, TeacherData and so on. The generic method needs to return the <code>StudentList&lt;T&gt;.</code>
  Thank you </p>