lundi 15 juillet 2019

Is there an IEnumerable

I'm surprised that not even IImmutableSet<T> gives me it, per my testing.

   Type                  |  Distinct Elements? | Covariant on T
================================================================
      IEnumerable<T>     |        No           |      Yes
----------------------------------------------------------------
 IReadOnlyCollection<T>  |        No           |      Yes
----------------------------------------------------------------
        ISet<T>          |        Yes          |      No
----------------------------------------------------------------
      IImmutableSet<T>   |        Yes          |      No 
================================================================   

My use case is when I want to define an interface like

interface IFoo<out T> where T : IBar
{
     // want to at least indicate to consumer of the class that these are distinct
     IImmutableSet<T> Bars { get; } 

     // ... 

}

Aucun commentaire:

Enregistrer un commentaire