Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#covariance and contravarianceSingle-choice MCQ

Why can a method with signature 'void Register(Action<Animal> handler)' accept an argument of type Action<object>?

// Animal is a class; Action<in T> is contravariant void Register(Action<Animal> handler) { /* ... */ } Action<object> log = o => Console.WriteLine(o); Register(log);