I am wondering if there is any set-like readonly interface that declares a Contains
method in C#. I don't want to just implement the ISet
interface because it has too many unnecessary methods.
My idea implementation would be like thi:
public class PositiveInt : IReadOnlySet<Int32> { public bool Contains(Int32 n){ return n > 0; } } public class CraEmployeeNames:IReadOnlySet<String> { public bool Contains(String n){ return !String.IsNullOrWhiteSpace(n) && n.StartsWith("Cra"); } }
I can define my own IReadOnlySet
, but want to ensure there is no built-in one before I do.
How about the IImmutableSet<T>
interface?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With