473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Decimal.ToString Method

How can I convert decimal value exactly to such format "0.00" (exactly with
dot, with ignoring of regional settings)?
Nov 17 '05 #1
2 7787
On Mon, 3 Oct 2005 14:01:56 +0400, "David Dvali"
<da*********@hotmail.com> wrote:
How can I convert decimal value exactly to such format "0.00" (exactly with
dot, with ignoring of regional settings)?


Decimal d1 = 1.25M;
string result =

d1.ToString("0.00",System.Globalization.CultureInf o.InvariantCulture);

--
Marcus Andrén
Nov 17 '05 #2
David Dvali wrote:
How can I convert decimal value exactly to such format "0.00" (exactly
with dot, with ignoring of regional settings)?


The best way to export data to string formats in a culture independant way
is to use the so-called InvariantCulture. Like this:

decimal val = 33.7m;
string strval = val.ToString(CultureInfo.InvariantCulture);

Here (MSDN) is more information about this: http://shrinkster.com/8fw
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: BA | last post by:
Hello, I have a string with a price in: "$14.95" I need to get it into a decimal. So I regex 'd the string and dumped the $. Debug mon shows a clean string "14.95" Then I do a...
3
by: Xavier Wargny | last post by:
Hi all and each! Since july, I'm working with dot NET technology. Confident with brand new tools it gave, I decided to use that new decimal type (related with the Database type...). After many...
3
by: Mark | last post by:
I have a Decimal or a Double - your choice. I'd like to print the number as string with a specified number of decimal places. Let's say my number 110.5, and I'd like to capture it in a string...
4
by: Ron | last post by:
Greetings, int i = 1, j = 6; double k = (double)i/j; Console.WriteLine(k.ToString()); Console.WriteLine(string.Format(k.ToString(), "0.00")); both yield 0.166666666666667 how can I make...
2
by: Piotr | last post by:
Hi I'm working with Datagrid containg decimal (editable) numbers. The user-entered numbers are read by decimal.Parse() method. However, Datagrid formats some decimals as "1", but some as (eg)...
15
by: Bob | last post by:
I'm about to convert to string and use regex, but I thought there must be something I'm missing here that already exists. Bob
7
by: Oenone | last post by:
Can anyone explain why the following happens? \\\ Dim d1 As Decimal = CDec("100") Dim d2 As Decimal = CDec("100.00") MsgBox(d1.ToString) 'displays "100" MsgBox(d2.ToString) 'displays...
12
by: ThunderMusic | last post by:
Hi, We have a part of our application that deals with millions of records and do some processing of them. We've achieved a pretty good performance gain by developping a custom DateTime.ToString...
2
by: pvong | last post by:
Newbie learning VB.Net. I have a simple DataReader and I can grab the info. The data is in numeric format like 123.99 and I want a TextBox to just display it just like that. When I use the code...
0
Frinavale
by: Frinavale | last post by:
Convert a Hex number into a decimal number and a decimal number to Hex number This is a very simple script that converts decimal numbers into hex values and hex values into decimal numbers. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.