title: C# compare property type when generic is used. With Reflection
body: <p>I have some generic class nested and I would like to retrieve with reflection the actual property type to implement some custom logic.</p>
  <pre><code>public class Base&lt;T&gt;
      public Base(T model)
      {
          this.model = model;
      }
      public void AMethod(){
          foreach (var property in this.model.GetType().GetProperties())
          {
              if(property.Name = &quot;Test&quot;) {
                  ...retrieve type        }     
          }
      }
  }
  </code></pre>
  <p>I have now a generic BaseModel with a Test property that use again the Generic type and are defined two derived class</p>
  <pre><code>BaseModel&lt;T&gt;
  {
      public int Id {get; set;}
      public string Name {get; set;}
      public MyClass&lt;T&gt; Test {get; set;}
  }
  
  FirstModel: BaseModel&lt;float&gt;{}
  SecondModel: BaseModel&lt;int&gt;{}
  </code></pre>
  <p>From the AMethod I would like to retrieve base on model if Test property is of type
  Myclass in a generic way (if possible) and also later on which is the specific type of T to switch operations based on type (MyClass or MyClass).</p>
  <hr />
  <p>&lt;===========================&gt; UPDATE &lt;===========================&gt;</p>
  <p>I've just created a test case in Fiddle. The structure of the class and inheritance could be complex. The purpose is to have a simple class exposed to the user to instantiate different Objects 'Floatinputs','FloatInputsSpecial', 'IntegerInputs'. All these derives from Base where T is a specific model. This Model can have or not a Test Property of Type MyObject.
  From the Base class constructor I would like to access this type.</p>
  <p><a href="https://dotnetfiddle.net/QismYC" rel="nofollow noreferrer">Fiddle test case fixed</a></p>
  <p>Thank you</p>