Double.ToString with N Number of Decimal Places
- by Ngu Soon Hui
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
}