根据我的测试,即使IImmutableSet<T>
都没有给我,我感到很惊讶。
Type | Distinct Elements? | Covariant on T
================================================================
IEnumerable<T> | No | Yes
----------------------------------------------------------------
IReadOnlyCollection<T> | No | Yes
----------------------------------------------------------------
ISet<T> | Yes | No
----------------------------------------------------------------
IImmutableSet<T> | Yes | No
================================================================
我的用例是当我想定义一个接口时
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; }
// ...
}