using System.Collections.Generic;
public abstract class EntityAbs
public abstract int SaveEntity();
public abstract class ListEntitiesAbs<T> where T : EntityAbs
protected List<T> InnerList;
public virtual int SaveEntities()
return InnerList.Sum(entity => entity.SaveEntity());
public class Item : EntityAbs
public override int SaveEntity()
throw new NotImplementedException();
public class Items : ListEntitiesAbs<Item>
public class ItemB : EntityAbs
public override int SaveEntity()
throw new NotImplementedException();
public class ItemsB : ListEntitiesAbs<ItemB>
public class ItemC : EntityAbs
public override int SaveEntity()
throw new NotImplementedException();
public class ItemsC : ListEntitiesAbs<ItemC>
public class AnAnotherClass
public int Save<T>(params ListEntitiesAbs<T>[] lists) where T : EntityAbs
for (int i = 0; i < lists.Length; i++)
static void Main(string[] args)
AnAnotherClass c = new AnAnotherClass();
Items items = new Items();
ItemsB items2 = new ItemsB();
ItemsC items3 = new ItemsC();
int result2 = c.Save<EntityAbs>(