title: Initialize Property of Generic Type
body: <p>I have read multiple posts but haven't found an appropriate answer for my problem.
  But there has to be one. So please be patient if this post really is an duplicate.</p>
  
  <p>I try to initialize a Property of a generic type implementing a generic interface.</p>
  
  <p>My interface looks basically like this:</p>
  
  <pre><code>public interface IMyInterface&lt;TType&gt; : IMyInterface
  {
      TType Value {get; set;}
  
      // ... and some more ...
  }
  
  public interface IMyInterface 
  {
      SetValue(string value);
  }
  </code></pre>
  
  <p>I have multiple Classes implementing <code>IMyInterface</code> without knowing them
  at the piece of code, where I need to set the value.</p>
  
  <p>Is it possible to inizialize the "Value"-Property without using the Name of the property?
  (Is there a "nice" way to do this?) - It isn't possible to use <code>SetValue&lt; TType ></code></p>
  
  <pre><code>void SetValue(object obj, string value)
  {
      // object obj implements IMyInterface&lt;???&gt;
      PropertyInfo valueInfo = typeof(obj).GetType().GetProperty("Value")
      valueInfo.SetValue(obj, Activator.CreateInstance(valueInfo.PropertyType))
  
      ((IMyInterface)obj).SetValue(value);
  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: - removed -</p>
  
  <p>EDIT 2:</p>
  
  <p>This structure is given:</p>
  
  <pre><code>public Interface IGeneric&lt;TType&gt; : INonGeneric
  {
      TType Value2 {get;}
  }
  
  public Interface INonGeneric
  {
      object Value1 {get;}
  }
  </code></pre>
  
  <p>using "Value1" from reflection is really easy:</p>
  
  <pre><code>INonGeneric myObject = (INonGeneric)givenObject;
  doSomething(myObject.Value1)
  </code></pre>
  
  <p>if i need to access "Value2" it isn't that easy. As one can see in my first example I had to use the following construct which not seems to be the best way to access "Value2", because the properties name is hardcoded.</p>
  
  <pre><code>PropertyInfo valueInfo = givenObject.GetType().GetProperty("Value2");
  object value = (object)valueInfo.GetValue(givenObject);
  </code></pre>
  
  <p>Is there any better solution?</p>