Say SampleA represents animals, and you do it
public class Bird : SampleA { }
public class Dog : SampleA { }
Test<Bird> b = new Test<Bird>();
b.DoStuff<Dog>();
The field actionnow knows how to act on the Bird, but not on the Dog that you passed, even if they have a common interface and a common base class.
You can do this work by changing this line
Action<T> action;
to
Action<SampleA> action;
source
share