What is covariance and contravariance?
Experience Level: Senior
Tags: .NET ASP.NET MVC ASP.NET WebAPI ASP.NET WebForms C#
Covariance enables you to pass a derived type where a base type is expected.
- Co-variance is like variance of the same kind.
- The base class and other derived classes are considered to be the same kind of class that adds extra functionalities to the base type. So covariance allows you to use a derived class where a base class is expected.
Hint: can accept big if small is expected.
Related C# job interview questions
Have you ever consumed some 3rd party API? What was it? Have you ever designed your own API? Could you describe it a bit?.NET Architecture ASP.NET WebAPI C# Web services Mid-level
.NET C# Mid-level
.NET C# Senior