In C#, i have an interface, and there are some class will implement this interface. i have a generic utility class, which i want to limit so that the utility class can only be declared using types implementing that interface, as show below, how can i do it??
public interface IMyInterface
{}
public class A : IMyInterface {} // can pass into UtilityClass
public interface B : IMyInterface{}
public class C : B {} // can pass into UtilityClass
public class D {} // can Not pass into UtilityClass
public class UtilityClass<T is IMyInterface>
{
// some utility function
}
Thanks.