Solved

Format number without decimal using c# and asp.net

Posted on 2006-10-24
2
8,556 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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