Hi,
Carlos wrote:
just wanted to know how can I just quickly round to nearest
100th, and use the first two decimal places of a double value in a
textbox, instead of all the decimals.
Brendan showed you how to round, if you need to. However, if all you are
doing is populating a text box, you will be converting the double to a
string anyway. You could just let the framework do it while formatting the
double as string.
double d = 12.3456789;
Console.WriteLine(d.ToString("N"));
This produces the following output:
12.35
As you can see, the number was correctly rounded during formatting and if
you are not doing anything else with it, then prior rounding in your code
isn't necesary. If you don't want thousands separated, you can use the
custom format string "0.00" instead of standard "N".
--
Chris Priede