is there any way to use generic class/method with 2 type that will not be the same?

51 views Asked by At

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

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

To be sure that the type "T" is implement the interface 'IDisposable'.

Is there some way to create generic class with 2 types that constrain the types to be different from one another like:

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

Thanks

0

There are 0 answers