Is there a way to use a generic class / method with 2 types that won't be the same?

I can create a generic class and use a "where" statement like:

public class TestClass<T> where T: IDisposable
{
    .... 
}

      

To make sure that type "T" implements the "IDisposable" interface.

Is there a way to create a generic class with 2 types that constrain the types to be different from each other, for example:

public class TestClass<T,K> where T!=K
{
    .... 
}

      

thank

+3


source to share





All Articles