title: How to pass a variable into a component's @typeparam in blazor
body: <p>I have created a TestComponent.razor</p>
  <pre><code>@typeparam TValue
  
  @code {
      private TValue Type { get; set; }
      [Parameter] public string String { get; set; }
  }
  
  </code></pre>
  <p>In the index.razor page I have the following:</p>
  <pre><code>@page &quot;/&quot;
  
  &lt;h1&gt;Hello, world!&lt;/h1&gt;
  
  Welcome to your new app.
  
  &lt;SurveyPrompt Title=&quot;How is Blazor working for you?&quot; /&gt;
  
  &lt;ComponentFactory.Data.SampleComponent TValue=&quot;@myType&quot; String=&quot;@myString&quot;&gt;&lt;/ComponentFactory.Data.SampleComponent&gt;
  
  @code{
      Type myType { get; set; } = typeof(string);
      string myString { get; set; } = &quot;hello&quot;;
  }
  </code></pre>
  <p>I cannot pass <code>Type myType</code> into <code>TValue</code>, unless I make <code>myType</code> a <code>@typeparam</code> of the current page</p>
  <p>Why is this happening and is there a way to pass variables into a component's <code>@typeparam</code>?</p>