1

In the following code:

interface IMyInterface<X>
{
    X Get();
}

class MyInterface : IMyInterface<int>
{
    int Get();
}

class MyClass<T, U> where T : IMyInterface<U>
{
    U Value;
}

U is always going to be a function of T. However, to use MyClass, I have to do this:

MyClass<MyInterface, int> instance;

It would be nice if I could just type:

MyClass<MyInterface> instance;

And have U be implied to be an int. Is there anyway to restructure my code so I don't need to specify U like that?

lifeformed
  • 525
  • 4
  • 16

0 Answers0