Link to home
Start Free TrialLog in
Avatar of Ashok
AshokFlag for United States of America

asked on

Easy question

double d1 = 8501.23;
double d2 = -199;
double d3 = 0;

I want it to format using String.Format to output as
@8,501.13@
@(199)@
@@
using
string sResult;
sResult = "@" + Formula_Result_Here + "@";

Thanks,
Ashok
Avatar of Kumaraswamy R
Kumaraswamy R
Flag of India image

Hi

Bellow URL Give some Information

http://www.csharp-examples.net/string-format-double/
Hi

Check -Ve Value then add (Value)
string Formula_Result_Here= string.empty
If (Given_value) < 0 then
{
Formula_Result_Here = "(" & Given_value & ")"
use
String.Format("@{0:#,0.##;(#,0.##); }@", 0);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jarrod
Jarrod
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
replace 0 at the end there with d1, d2 and d3 :)