Check T generic type has property S (generic) in c#
<p>class A</p>

<pre><code>class A{
...
}
</code></pre>

<p>class B</p>

<pre><code> class B:A{
    ...
 }
</code></pre>

<p>class C </p>

<pre><code> class C:A{
    B[] bArray{get;set;}
 }
</code></pre>

<p>I would like to check if T has a property type of S , create instance of S and assignment to that propery :</p>

<pre><code>public Initial&lt;T,S&gt;() where T,S : A{
   if(T.has(typeof(S))){
      S s=new S();
      T.s=s;
   }
}
</code></pre>