title: How to make a generic type that must inherit from a class with generic type in Blazor?
body: <p>I'm trying to make a class that have 3 generic types and one of the types must inherit from that other class that have the other 2 generic types.</p>
  
  <p>What I really need is that <code>IForm</code> inherits from <code>FormComponent</code> so it have all of it's methods implemented.</p>
  
  <p>Form.razor</p>
  
  <pre><code>@typeparam TForm
  @typeparam TModel
  @typeparam TResult
  
  &lt;EditForm Model="@Model" OnValidSubmit="@HandleValidSubmit"&gt;
      @ChildContent
  &lt;/EditForm&gt;
  </code></pre>
  
  <p>Form.razor.cs</p>
  
  <pre><code>public partial class Form&lt;TForm, TModel, TResult&gt;  
      where TForm : FormComponent&lt;TModel, TResult&gt;
  {
  
      [Parameter]
      public TForm FormRef { get; set; }
  
      [Parameter]
      public EventCallback&lt;TResult&gt; OnValidSubmit { get; set; }
  
      [Parameter]
      public TModel Model { get; set; }
  
      // ... 
      // some other properties
  }
  </code></pre>
  
  <p>FormComponent.cs</p>
  
  <pre><code>public abstract class FormComponent&lt;TModel, TResult&gt; : BaseDomComponent
  {        
      [CascadingParameter]
      public TModel Model { get; set; }
  
      public abstract TResult OnValidSubmit();
  
      // ... 
      // some other properties   
  }
  </code></pre>
  
  <p>Code from where I use Form</p>
  
  <pre><code>&lt;Form Model="@Entity" FormRef="@_formRef" OnValidSubmit="@HandleValidSubmit"&gt;
      &lt;XYZForm @ref="_formRef" /&gt;
      &lt;Button ButtonType="ButtonType.Submit"&gt;Submit&lt;/Button&gt;
  &lt;/Form&gt;
  </code></pre>
  
  <p>But this gives me the error </p>
  
  <blockquote>
    <p>Error CS0314  The type 'TForm' cannot be used as type parameter 'TForm' in the generic type or method 'Form&lt; TForm, TModel, TResult >'. There is no boxing conversion or type parameter conversion from 'TForm' to 'Core.Web.Base.FormComponent&lt; TModel, TResult >'</p>
  </blockquote>
  
  <p>I searched this error in alot of places but didn't found any case where there was 3 generic types. I also read the <a href="https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0314" rel="nofollow noreferrer">docs</a>  but couldn't use that to solve my case.</p>