How to use same interface two times with diferrent template parameters, in an interface?

后端 未结 6 1540
谎友^
谎友^ 2020-12-06 14:02

I Think it would be more clearer with this example. We Want to see two methods with diferrent parameters in the processor class. \"int Process (int value);\" \"double Proce

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 14:23

    Sorry to see you had so many downvotes on this, I'm facing the same issue.

    Sadly it doesn't seem to be possible - this MSDN page lists the only possible generic type constraints, and none can express the constraint "T and U can be any types, but must have distinct inheritance hierarchies" http://msdn.microsoft.com/en-us/library/d5x73970(v=vs.80).aspx

    We really need some kind of where T !: U or where T, U disjoint syntax; but as it stands there is no way to specify to the compiler that instances of TItem1 and TItem2 can never be substitutable for each other.

提交回复
热议问题