Solved

Format number without decimal using c# and asp.net

Posted on 2006-10-24
2
8,553 Views
Last Modified: 2011-08-18
Experts,

I have the following code:

double dblDeductible = double.Parse(reader["DEDUCTIBLE_SIR"].ToString());
this.txtDeductible.Text = dblDeductible.ToString("C");

and I get the result of $2000.00.  I know if I change ToString from a "C" to a "G", I drop the dollar sign.  I want to know how to drop the decimal (".00") so it becomes just 2000 or $2000.

Thanks for any help...
0
Comment
Question by:michael1174
2 Comments
 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
You can use any manual formatting you want (I am not sure a built in one will do so)

For example:
double dblDeductible = double.Parse(reader["DEDUCTIBLE_SIR"].ToString());
this.txtDeductible.Text = dblDeductible.ToString("9999");

Where 9 indicates an optional number and 0 is a required number (i.e. will pad with 0 if a required digit is not present)
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 125 total points
Comment Utility
Try either:

    dblDeductible.ToString("C0");

Or:

    dblDeductible.ToString("G0");

To display with no decimal places.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now