How can I parse "101050" to currency

I have a string "101050" and I want to convert it to "$1,010.50"

how can I do that please!



Answer this question

How can I parse "101050" to currency

  • pvulcan

    Oops, yes, thank you mc for pointing it out.

  • Repi3

    string str = "101050";

    double d = (Int32.Parse(str)) / 10.0;

    Console.WriteLine(string.Format("{0:c}",d));



  • PeterVrenken

    Jeremy,
    I guess you need "/100.0"

    --mc


  • Vikasumit

    And don't use double, use decimal, otherwise you may get floating point errors.

  • Nep23

    what I did was just adding them instead of converting 101050

    string1 = "$" +string1 .Insert(string1.Length - 2, "."); //$1010.50

    better than nothing, if you guys have any suggestions please let me know, I'm gonna bother with the comma

     


  • How can I parse "101050" to currency