title: .NET reflection - converting array-type property value into comma-separated string
body: <p>I am inspecting .NET objects using reflection to dump them to a log.</p>
  
  <p>I've hit a snag - what if a property is an array type? I do get the <code>PropertyInfo</code> structure for that property, and I can see that the property is an array, and I can even get the value of that array property:</p>
  
  <pre><code>if(propertyInfo.PropertyType.IsArray)
  {
      var value = propertyInfo.GetValue(myObject, null);
  }
  </code></pre>
  
  <p>but now I'm stuck. When I look in the Visual Studio debugger, it shows as <code>int[3]</code> - so VS knows it's an array of three integers - but how can I convert this to a comma-separated string representing these three integers now?</p>
  
  <p>I tried things like</p>
  
  <pre><code>string.Join(", ", value);
  </code></pre>
  
  <p>and others - but I'm always struggling with the fact that <code>value</code> is "dynamic", e.g. it could be a <code>int[]</code> or a <code>decimal[]</code> or even something else - so I cannot statically type it.... and if I don't type it, then the <code>string.Join()</code> returns strange results (definitely not what I'm looking for...)</p>
  
  <p>Is there any clever way to convert this "array of something" to a comma-separated string without a lot of <code>if(...)</code> and <code>else { .... }</code> clauses??</p>
  
  <p>Somehow I'm in a brain-freeze here right now - any ideas to thaw this freeze up would be most welcome!</p>