Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Format number without decimal using c# and asp.net

Posted on 2006-10-24
2
Medium Priority
?
8,575 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 500 total points
ID: 17798198
Try either:

    dblDeductible.ToString("C0");

Or:

    dblDeductible.ToString("G0");

To display with no decimal places.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

688 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