title: Convert card numbers to XXXX-XXXX-XXXX-0000 Format
body: <p>I have a 16 character string that comes through something like this:</p>
  
  <pre><code>1234567891234567
  </code></pre>
  
  <p>I need to be able to format the string as it would appear in a system i.e</p>
  
  <pre><code>XXXX-XXXX-XXXX-4567
  </code></pre>
  
  <p><strong>NOTE</strong> that the 4567 digits shown above relate to the last four digits of the card number.</p>
  
  <p><a href="https://stackoverflow.com/questions/4128263/format-a-social-security-number-ssn-as-xxx-xx-xxxx-from-xxxxxxxxx">This</a> question helps format the string to something like <code>1234-5678-9123-4567</code></p>
  
  <p>But it does not help with the format required above. </p>
  
  <p>While looking for answers I also came across the following solution:</p>
  
  <pre><code>    string[] subStrings = Enumerable.Range(0, 4).Select(n =&gt; cardNumber.Substring(n * 4, 4)).ToArray();
      string result = String.Format("{0}-{1}-{2}-{3}", subStrings);
  </code></pre>
  
  <p>but again this will only output the string as something like <code>1234-5678-9123-4567</code></p>
  
  <p>I seem to have reached part of the solution, but cant format the rest.</p>