I have the following interface:
public interface IService<T>
{
void AddOrUpdate(T tab);
bool Available();
Can I limit this interface so that it can only be used for certain types?
What’s the significance of the parameter name “tab”. Could this be any sensible name or is there a connection with where the interface is used?
Yes, you can restrict generic type usage like so:
In this case, T can only be a type that implements (or inherits from, be it a class)
IServicableType.No, the parameter name does not matter. The parameter name of the class’s method does not need to reflect the parameter name of the interface. This is because parameter names do not effect a method’s signature. Only the signatures must match.