title: C# generic Interface implementation to derived class
body: <p>I am stuck in implementation of generic class and interface. I am not sure what i wanted to do is possible or not.</p>
  
  <p>here is my code:-
  I have defined a generic class whose type not define like</p>
  
  <pre><code>public class Response&lt;T&gt;
  {
  
      public T Data { get; set; }
  
      public Response()
      {
          Data = default(T);
      }
  }
  </code></pre>
  
  <p>and a Interface which right now have one function</p>
  
  <pre><code>public interface  IOInterface&lt;T&gt; where T : Response&lt;T&gt;
  {
      Response&lt;T&gt; ReadAdvantechChannel(Dictionary&lt;string, string&gt; IOParameters);
  }
  </code></pre>
  
  <p>And one derive class who will implements this interface :-</p>
  
  <pre><code>public class AdvantechOperation : IOInterface&lt;T&gt; 
  {
      public Response&lt;AIRecordInfo&gt; ReadAdvantechChannel(Dictionary&lt;string, string&gt; IOParameters)
      {
          Response&lt;AIRecordInfo&gt; resp = new Response&lt;AIRecordInfo&gt;();
      }
  }
  </code></pre>
  
  <p>and AIrecordinfo is again class</p>
  
  <pre><code>public class AIRecordInfo
  {
      double[] ArryMaxValueAIdouble;
      double[] ArryMinValueAIdouble;
      double[] ArryAVGValueAIdouble;
  }
  </code></pre>
  
  <p>what i want to do that implement a class who implement define interface but return type of interface function is not clear for my future derived class thats why i have made it generic and try to implement it my present class "AdvantechOperation". My interface will have three functions and all function return type will different to each other thats why i made it generic return type Response and in my present class AdvantechOperation,  T replaced by AIRecordInfo.
  But I am facing below Error while compiling this  project </p>
  
  <blockquote>
    <p>Error 7   The type 'T' cannot be used as type parameter 'T' in the
    generic type or method 'IOModule.IOInterface'. There is no boxing
    conversion or type parameter conversion from 'T' to
    'IOModule.Response'.   D:\MTS\SMS\DAQAdvantechdll\DAQAdvantechdll\IOCommunication.cs   28  18  IOModule
    Error 8   'IOModule.AdvantechOperation' does not implement interface
    member
    'IOModule.IOInterface.ReadAdvantechChannel(System.Collections.Generic.Dictionary)'.
    'IOModule.AdvantechOperation.ReadAdvantechChannel(System.Collections.Generic.Dictionary)'
    cannot implement
    'IOModule.IOInterface.ReadAdvantechChannel(System.Collections.Generic.Dictionary)'
    because it does not have the matching return type of
    'IOModule.Response'.   D:\MTS\SMS\DAQAdvantechdll\DAQAdvantechdll\IOCommunication.cs   28  18  IOModule</p>
  </blockquote>