[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Convert decimal to string C#

Posted on 2013-06-18
2
Medium Priority
?
949 Views
Last Modified: 2013-06-18
I have a decimal variable that I need to convert to a string  that has only 2 decimal places.

Convert 25.69624953583364277757148162

To "25.69"

What is the c# expression?

Thanks
0
Comment
Question by:Dovberman
[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 60

Accepted Solution

by:
Kevin Cross earned 1200 total points
ID: 39256256
Hi.

If you have a decimal variable, you can use the ToString() method.
MSDN: http://msdn.microsoft.com/en-us/library/0b22a4x2.aspx

It uses the standard numeric format codes.
MSDN: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
Just pick the format that matches your intended use. For example, ToString("C2"), ToString("F2"), or ToString("N2") where the 2 represents the number of decimal places.
0
 

Author Closing Comment

by:Dovberman
ID: 39256392
Just what I needed.

Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

656 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