title: How can we type cast IEnumerable<KeyValuePair<string, IEnumerable<ClassA>>> objOld into IEnumerable<KeyValuePair<string, IEnumerable<ClassB>>> objNew?
body: <p>I have an object <code>IEnumerable&lt;KeyValuePair&lt;string, IEnumerable&lt;ClassA&gt;&gt;&gt; objOld;</code> which i want to cast  into <code>IEnumerable&lt;KeyValuePair&lt;string, IEnumerable&lt;ClassB&gt;&gt;&gt; objNew;</code>.</p>
  
  <p>ClassA and ClassB both have same objects</p>
  
  <pre><code>public class ClassA
  { `public string str1 { get; set; }
      public string str2 { get; set; } 
      public int newNum { get; set; } `
  }
  
  public class ClassB
  { `public string str1 { get; set; }
      public string str2 { get; set; } 
      public int newNum { get; set; } `
  }
  </code></pre>
  
  <p>I tried following but it is generating exception.</p>
  
  <pre><code>objNew = objOld.Cast&lt;IEnumerable&lt;KeyValuePair&lt;string, IEnumerable&lt;ClassB&gt;&gt;&gt;&gt;();
  </code></pre>
  
  <p>Please let me know possible ways to do so.</p>