I have a dictionary and it’s type is Dictionary<int, fooClass> fooDic and another dictionary is Dictionary<int, string> barlist and I’m using this linq to return result
var foobarList = fooDic.Where(kvp =>
!barlist.ContainsKey(((fooClass)kvp.Value)._fooID))
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
This will return result of fooDic type. But I need to type cast output as barlist(Dictionary<int, string>) type. How?
If it’s a rather simple transformation, the key is the last part of your
statement. Where you currently use
kvp => kvp.Value, you substitute that forkvp => kvp.Value._foobarValue.Edited for “full” solution in accordance with OP’s comments.