I have a method that takes in 2 numbers. The first number is the value that I want to set (or format) and the second number is the precision to use.
public double ReduceNumber(double Test, int Precision)
{
}
Let’s say I pass in the parameters 125.6023867 and 4. I would like the return value to be 125.6023. I know how to use the FormatNumber() function in VB but now that I am trying to convert to C# I am drawing a blank. All that I can find online is String.Format() which helps but I don’t know how to code for a format that can change regularly.
A formatted string:
This is using the standard numeric format string “F” with a precision specifier.
A rounded double:
A point about style – parameter names are normally pascalCase in C#.