2017-01-17 7 views
-1

特定の型を持つ2つのクラスによって実装されるインターフェイス内にジェネリック型メソッドが必要です。ジェネリックインターフェイスから継承するC#

public interface IInterface 
{ 
    IEnumerable<T> ExecStoredProc(string x, DateTime date, 
      int y, string statistics); 
} 

二つのクラス:

public class Class1 : Iinterface 
{ 
    IEnumerable<Class1Type> ExecStoredProc(string x, DateTime date, 
      int y, string statistics); 
} 

public class Class2: Iinterface 
{ 
    IEnumerable<Class2Type> ExecStoredProc(string x, DateTime date, 
      int y, string statistics); 
} 

これが可能であるこれはインターフェースのですか?

ありがとうございます。

+0

なぜダウン投票? – user1647160

答えて

1

これも可能ですが、インターフェイスも汎用である必要があります。

public interface IInterface<T> 
{ 
    IEnumerable<T> ExecStoredProc(string x, DateTime date, 
      int y, string statistics); 
} 

そして、インターフェースを実装するクラスは、特定のタイプのためのインターフェイスを実装する必要が

public class Class2 : IInterface<Class2Type> 
+1

ありがとうございました。それはうまくいった。 – user1647160