using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
class ActionCollection<T> : Collection<T>
{
private Action<T> action;
public ActionCollection(Action<T> action)
{
this.action = action;
}
protected override void InsertItem(int index, T item)
{
action(item);
base.InsertItem(index, item);
}
}
public class MainClass
{
public static void Main()
{
ActionCollection <string> ac = new ActionCollection<string>(Console.WriteLine);
ac.Add("console");
}
}
console