Have you failed a job interview?
Send us your job interview questions and get correct answers.
What is covariance and contravariance?
Experience Level: Senior
Tags: .NETASP.NET MVCASP.NET WebAPIASP.NET WebFormsC#
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
What is a namespace in C# and what is it good for?C# Junior
What is abstract class and what is it good for?C# Medior
Have you ever consumed some 3rd party API? What was it? Have you ever designed your own API? Could you describe it a bit?.NETArchitectureASP.NET WebAPIC#Web services Medior
What is serialization/deserialization? What types of serialization do you know?.NETC# Medior
What is a MultiCastDelegate? What is it good for? Give some real use case.NETC# Senior