Variant types as parameters and return values

suggest change

If a covariant type appears as an output, the containing type is covariant. Producing a producer of Ts is like producing Ts.

interface IReturnCovariant<out T>
{
    IEnumerable<T> GetTs();
}

If a contravariant type appears as an output, the containing type is contravariant. Producing a consumer of Ts is like consuming Ts.

interface IReturnContravariant<in T>
{
    IComparer<T> GetTComparer();
}

If a covariant type appears as an input, the containing type is contravariant. Consuming a producer of Ts is like consuming Ts.

interface IAcceptCovariant<in T>
{
    void ProcessTs(IEnumerable<T> ts);
}

If a contravariant type appears as an input, the containing type is covariant. Consuming a consumer of Ts is like producing Ts.

interface IAcceptContravariant<out T>
    {
        void CompareTs(IComparer<T> tComparer);
    }

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Generics:
* Variant types as parameters and return values

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
57 Generics
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script