c# - How do I convert a string to a decimal, and format it for pretty output? -


i want convert "372551.40" decimal. need see after converting format 372.551,40.

to convert decimal, can use:

decimal decimalvalue = 0.0;  decimalvalue = decimal.parse("372551.40"); 

or

decimal.tryparse("372551.40", out decimalvalue); 

to display in specific format can do:

cultureinfo tr = new cultureinfo("tr-tr");     string formattedvalue = decimalvalue.tostring("c", tr); //result 372.551,40 ytl  formattedvalue = decimalvalue.tostring("0,0.00", tr); //result 372.551,40 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -