title: initialize an IEnumerable property using reflection in c# (propertyInfo)
body: <p>Assuming a class (could be others)</p>
  
  <pre><code>class Foo()
  {
       IEnumerable&lt;int&gt; SomeNumbers { get; set; }
       IEnumerable&lt;string&gt; SomeStrings { get; set; }       
       int[] ArrayOfInt { get; set; }
       List&lt;int&gt; AListOfIntegers { get; set; }
  }
  </code></pre>
  
  <p>And a method</p>
  
  <pre><code>void Initialize(object obj)
  {
       var props = obj.getType().GetProperties();
       foreach(var prop in props)
       {
           //Some logic in case property is a single value, this is using:
           //Convert.ChangeType(value, property.PropertyType, null)
  
           var list = //Do Some Magic
           prop.SetValue(obj, list, null);
       }
  }
  </code></pre>
  
  <p>How to create a list of the right type?</p>
  
  <p>I tried:</p>
  
  <pre><code>var list = property.PropertyType.GetConstructor(new CType[0]).Invoke(new object[0]);
  </code></pre>
  
  <p>But this don't work since IEnumerable does n't have constructors (it is an interface), but any supertype would be fine here.</p>
  
  <pre><code>var list = Enumerable.Empty&lt;property.PropertyType.MemberType&gt;();
  </code></pre>
  
  <p>Isn't even legal</p>