Concat/Union Tables in LINQ

后端 未结 2 571
盖世英雄少女心
盖世英雄少女心 2021-01-13 07:17

This current project is more of a proof of concept for a larger project. I have two \"tables\" (represented as lists below), CatList and DogList, t

2条回答
  •  迷失自我
    2021-01-13 07:41

    The generic lists are from different types (Dog and Cat), you have to "cast" them to the target interface before concatenation:

    var list1 = DogList.Cast();
    var list2 = CatList.Cast();
    
    var bothLists = list1.Concat(list2); //optional .ToList()
    

提交回复
热议问题