Double.ToString with N Number of Decimal Places
Posted
by Ngu Soon Hui
on Stack Overflow
See other posts from Stack Overflow
or by Ngu Soon Hui
Published on 2010-06-17T07:45:14Z
Indexed on
2010/06/17
7:53 UTC
Read the original article
Hit count: 169
c#
I know that if we want to display a double
as a two decimal digit, one would just have to use
public void DisplayTwoDecimal(double dbValue)
{
Console.WriteLine(dbValue.ToString("0.00"));
}
But how to extend this to N
decimal places, where N
is determined by the user?
public void DisplayNDecimal(double dbValue, int nDecimal)
{
// how to display
}
© Stack Overflow or respective owner