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
Post a Comment