title: Why does Web API parse a comma-separated int array in an action path correctly but cannot parse a comma-separated decimal array?
body: <p>I have a Web API project written in .NET Core 2.1.  I'm trying to create an action that can take an array of decimal values as a parameter.</p>
  <p>If I define the parameter data type as <code>string[]</code> or <code>int[]</code> then when I call the action, passing in a comma-separated string, Web API is able to parse that into an array of strings or an array of ints.</p>
  <p>However, if I change the data type of the parameter to <code>decimal[]</code> and call it again with the same comma-separated string, Web API strips out the commas and concatenates the values together to form a single large decimal.</p>
  <p>Why does it split a comma-separated string correctly if the parameter is defined as an <code>int[]</code> but not if it's a <code>decimal[]</code>?</p>
  <p>Example:</p>
  <p>Here's my action:</p>
  <pre><code>[HttpGet(&quot;details/{shipmentDetailIds}&quot;)]
  public async Task&lt;List&lt;ShipmentDetail&gt;&gt; GetByShipmentDetailIds(decimal[] shipmentDetailIds)
  {
      ...
  }
  </code></pre>
  <p>Here's what I'm passing in as an argument when I call it via Postman:
  <a href="https://i.stack.imgur.com/0ZHQh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ZHQh.png" alt="Values passed in when calling via Postman" /></a></p>
  <p>Here's how the array is parsed in the action when I define the parameter as a decimal array:</p>
  <p><a href="https://i.stack.imgur.com/opwSJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/opwSJ.png" alt="How the argument is parsed as a decimal array" /></a></p>
  <p>You can see it effectively stripped out the commas and concatenated the three numbers together into a single large decimal value.</p>
  <p>But if I change the data type of the parameter to <code>int[]</code> and call it again from Postman with the same argument values, this time Web API parses the argument correctly, splitting it into three numbers:</p>
  <p><a href="https://i.stack.imgur.com/reEls.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/reEls.png" alt="How the same argument is parsed as an int array" /></a></p>
  <p>Why the different behaviour when parsing the same argument as a decimal array and an int array?  And how can I get it to parse the comma-separated decimals correctly?</p>
  <p><strong>EDIT:</strong> I know I could get this to work by passing the array in the query string.  However, I'm updating an existing app where all the arguments are passed in the URL path, rather than the query string, so I'd like to continue to use the same convention.  Another alternative would be to use an integer array, since that works.  However, although the shipmentDetailIds currently appear to be integers the data type in the warehouse management system is decimal.  I would prefer to stick to the correct data type in case shipments start coming through with decimal-style shipmentDetailIds in future.</p>