0
0
C Sharp (C#)programming~10 mins

Contravariance with in keyword in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a contravariant interface using the in keyword.

C Sharp (C#)
public interface IProcessor<[1] T> { void Process(T item); }
Drag options to blanks, or click blank then click option'
Ain
Bout
Cref
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Using out instead of in for contravariance.
Trying to use ref or var which are invalid here.
2fill in blank
medium

Complete the code to assign a contravariant interface reference correctly.

C Sharp (C#)
IProcessor<object> objProcessor = new Processor<string>();
IProcessor<string> strProcessor = [1];
Drag options to blanks, or click blank then click option'
Anew Processor<object>()
Bnull
Cnew Processor<int>()
DobjProcessor
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning new Processor() directly to IProcessor which is invalid.
Confusing covariance and contravariance directions.