Code separator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michael chauruka
    New Member
    • May 2007
    • 1

    Code separator

    I have the following code and want my total to include a comma as a thousand separater. how do i go about it
    [code=c]
    else if (itemType == 1) // debit
    {
    total += Convert.ToDecim al(rec.getAmoun t());
    //total=Convert.T oDecimal(total) ;
    outFile.Write(" {0} {1}", rec.getAmount() .PadRight(13, ' '), total.ToString( ).PadLeft(13, ' '));
    }
    else
    {
    total +=Convert.ToDec imal(rec.getAmo unt());
    outFile.Write(" {0} {1}", rec.getAmount() .PadRight(13, ' '), total.ToString( ).PadLeft(13, ' '));
    }
    if (putTemplate) outFile.Write(" |"); else outFile.Write(" ");
    putEndOfLine();
    recnDetailNeede d = disp.needRecn() ;
    [/code]
  • ghousebarq
    New Member
    • May 2007
    • 5

    #2
    Hi

    Below is the code to convert a double to specific currency format.

    Double MyVal = 78692.92786;
    string CurrencyFormat = string.Format(" {0:##,###,##}", MyVal);

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      The .ToString() on numbers can take a format string. Check MSDN for a list of NumberFormatInf o's. One of them is specifically designed to add a thousands seperator

      Comment

      Working...