, .
:
public class Foo:IFoo
{
public void DoSomething()
{
}
public void DoSomethingWithFoo()
{
}
}
:
public void RegisterFoosGeneric<T>(T item, Action<T> action) where T : IFoo
{
action(item);
}
public void RegisterFoos(IFoo item, Action<IFoo> action)
{
action(item);
}
:
test.RegisterFoosGeneric(new Foo(), x=>x.DoSomethingWithFoo());
, :
test.RegisterFoos(new Foo1(), x=>x.DoSomethingWithFoo1());