java DecimalFomat in C#
I have these code which I have converted from Java. Now I need to change this DecimalFormat in C# Syntex.
private string formatValue(double dVal)
{
DecimalFormat df = new DecimalFormat();开发者_StackOverflow社区
df.applyPattern("######.###");
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.DecimalSeparator = '.';
df.DecimalFormatSymbols = dfs;
return df.format(dVal);
}
Kindly help me to do the same.
Thanks!
Use number.ToString("######.###")
to achieve the same in C#
I hope this will help:
var nf = new System.Globalization.NumberFormatInfo();
nf.NumberDecimalSeparator = "-";
double d = 123456.789;
d.ToString("########.###",nf);//prints 123456-789
精彩评论