?
Solved

Easy question

Posted on 2010-01-07
5
Medium Priority
?
205 Views
Last Modified: 2013-12-17
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
0
Comment
Question by:Ashok
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 26205910
Hi

Bellow URL Give some Information

http://www.csharp-examples.net/string-format-double/
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 26205939
Hi

Check -Ve Value then add (Value)
string Formula_Result_Here= string.empty
If (Given_value) < 0 then
{
Formula_Result_Here = "(" & Given_value & ")"
0
 
LVL 13

Expert Comment

by:zadeveloper
ID: 26206312
use
String.Format("@{0:#,0.##;(#,0.##); }@", 0);

Open in new window

0
 
LVL 13

Accepted Solution

by:
zadeveloper earned 1000 total points
ID: 26206327
sorry - there is a " " to many in there :)

String.Format("@{0:#,#.##;(#,#.##)}@", 0)

Open in new window

0
 
LVL 13

Expert Comment

by:zadeveloper
ID: 26206329
replace 0 at the end there with d1, d2 and d3 :)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question