Is it possible to join two types together (like doing .AddRange in a list) using for example reflection? Something like in this reponse https://stackoverflow.com/a/8702650/13112059, but here the data from the target object gets replaced.
public class ItemsResponse
{
public List<Items> Items{ get; set; } = new List<Items>();
}
In my case I receive a response from an API and cast the data to this type for example which is only defined at runtime, but then I also need to do another request where I receive data from the same type and I wanted to join this objects together to return them as one.
Example of a request:
public static async Task<T> Query()
{
var response = new T();
var response2 = new T();
response = (T)await RequestAsync(); // First request
/// ...
response2 = (T)await RequestAsync(); // Second request
// I want to return an object containing data from the two responses
}
Thanks!