Solved

Format number without decimal using c# and asp.net

Posted on 2006-10-24
2
8,554 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
ID: 17798168
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
ID: 17798198
Try either:

    dblDeductible.ToString("C0");

Or:

    dblDeductible.ToString("G0");

To display with no decimal places.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

929 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

13 Experts available now in Live!

Get 1:1 Help Now