title: Generics: Passing an int value instead of type
body: <p>Here is the issue I am trying to solve. I need to expose a set of custom types to my users. To give some examples:</p>
  <pre><code>var int2 = new FixedArray&lt;int, VM2&gt;(); // &lt;=&gt; ImmutableArray&lt;int&gt; / Length = 2
  var double3 = new FixedArray&lt;double, VM3&gt;(); // &lt;=&gt; ImmutableArray&lt;double&gt; / Length = 3
  var ushort6 = new FixedArray&lt;ushort, VM6&gt;(); // &lt;=&gt; ImmutableArray&lt;ushort&gt; / Length = 6
  [...]
  </code></pre>
  <p>To avoid boilerplate code, I tried to use generics for the second parameter, and ended up with something like this:</p>
  <pre><code>sealed class FixedArray&lt;T, VM&gt; : IStructuralComparable where T : struct where VM : IVM, new()
  {
      public T[] array { get; init; }
      public FixedArray()
      {
          VM vm = new VM(); // hopefully the compiler will do something smart
          array = new T[vm.Value];
      }
  
      public int CompareTo(object? other, IComparer comparer) =&gt; ((IStructuralComparable)array).CompareTo(other, comparer);
  }
  </code></pre>
  <p>with:</p>
  <pre><code>interface IVM
  {
      int Value { get; }
  }
  sealed class VM2 : IVM
  {
      public VM2() { Value = 2; }
      public int Value { get; }
  }
  sealed class VM3 : IVM
  {
      public VM3() { Value = 3; }
      public int Value { get; }
  }
  sealed class VM6 : IVM
  {
      public VM6() { Value = 6; }
      public int Value { get; }
  }
  </code></pre>
  <p>Is there any other trick to pass an integer in my case (avoid highly redundant code in between the different array size) ?</p>
  <hr />
  <p>Update:</p>
  <p>VM can be:</p>
  <ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
  <li>6</li>
  <li>8</li>
  <li>16</li>
  <li>24</li>
  <li>1-2</li>
  <li>1-3</li>
  <li>1-8</li>
  <li>1-32</li>
  <li>1-n</li>
  <li>2-2n</li>
  <li>2-n</li>
  <li>3-3n</li>
  <li>3-n</li>
  </ul>