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.