title: C# How to set PropertyInfo value when its type is a List<T> and I have a List<object>
body: <p>I have an object with a generic List property where T is a primitive value, string, or enum. The generic argument of this list will never be a reference type (except for string). Now, I have another List who's argument type is object. Is there a way to set that property's value with my object list? As in: </p>
  
  <pre><code>List&lt;object&gt; myObjectList = new List&lt;object&gt;();
  myObjectList.Add(5);
  
  property.SetValue(myObject, myObjectList, null);
  </code></pre>
  
  <p>When I know that the property's real type is:</p>
  
  <pre><code>List&lt;int&gt;
  </code></pre>
  
  <p>The only solution I can see to it is making a hard coded switch that uses the generic argument's type of the list property and creates a type safe list. But it would be best if there were a general case solution. Thanks!</p>