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

后端 未结 6 1525
谎友^
谎友^ 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:29

    You could probably use this kind of implementation. You'll loose some generic arguments:

    public interface IBase 
        where TM : bType
        where TPkey : new ()        
    {
        TM Get(TPkey key);
    }
    
    public interface IABase : IBase {}
    public interface IBBase : IBase {}
    
    public class Root  :
        IABase,
        IBBase 
        where TM : MType 
        where TPM : PMType 
        where TPK : new()
    {
        ConcreteTmA IABase.Get(TPK key)
        {
        }
    
        ConcreteTmB IBBase.Get(TPK key)
        {
        }
    }
    

提交回复
热议问题