I have this class:
public class Itemcollection : Item
{
public List<Item> Items{ get; set; }
}
And now I add the item(s) to a List
if (item is Itemcollection collection)
{
list.AddRange(collection.items);
}
else
{
list.Add(item);
}
Is there way to avoid the object check (if (item is Itemcollection collection)) and do this on a more generic way or somthing similar.