title: Format decimal value to currency with 2 decimal places
body: <p>I am getting data from a csv file and parsing it to my application. In my csv file I have a column <code>price</code> whose value I use as of course the price of an item in my project. </p>
  
  <p>However, the price in the csv file does not contain trailing 0s,
  For example, if the price of and item is <code>$5.00</code>, the csv file has it as <code>$5</code>, if the price is <code>$9.60</code>, the csv has it as <code>$9.6</code>. Other prices such as <code>$9.56</code> are fine though.</p>
  
  <p>This is how I retrieve the price from the csv file:</p>
  
  <pre><code> Price = string.IsNullOrEmpty(columns[3].Trim()) ?
       null : (decimal?)decimal.Parse(columns[3]), 
  </code></pre>
  
  <p>In my class <code>Price</code> is set as <code>public decimal? Price { get; set; }</code>.</p>
  
  <p>How do I format what is returned to fix this problem?</p>
  
  <pre><code>Price = String.Format("Price: {0:C}", 
       string.IsNullOrEmpty(columns[3].Trim()) ? 
          null : (decimal?)decimal.Parse(columns[3]));
  </code></pre>
  
  <p>I tried the above but didn't work.</p>
  
  <p>How do I fix it so that values in the csv as <code>$5.9</code> are formatted to <code>$5.90</code>.</p>
  
  <p>EDIT:</p>
  
  <p>Tried:</p>
  
  <pre><code>Price=decimal.Round(string.IsNullOrEmpty(columns[3].Trim()) ? 
      null : 
      (decimal?)decimal.Parse(columns[3]), 2, MidpointRounding.AwayFromZero);
  </code></pre>
  
  <p>Not sure if I did that right?</p>
  
  <p>Also, I'm not certain how I can use the below option in my code:</p>
  
  <pre><code>decimalVar.ToString ("#.##");
  </code></pre>
  
  <p>Also tried:</p>
  
  <pre><code> Price = string.IsNullOrEmpty(columns[3].Trim()) ? 
        null : (decimal?)decimal.Parse(columns[3], NumberStyles.Currency)
  </code></pre>
  
  <p>But still doesn't work.</p>