By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,606 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,606 IT Pros & Developers. It's quick & easy.

Convert C# string to decimal

P: n/a
How do you convert a string in C# to decimal?

STom
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi STom,

You can use decimal.Parse();

Joe
--
http://www.csharp-station.com

"STom" <st***********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
How do you convert a string in C# to decimal?

STom

Nov 16 '05 #2

P: n/a
Hi S,

Use double's built-in Parse method:

string s = "123.45";
double d = double.Parse(s);

All System numerical value types (int, long, float, etc) have a parse
method.

ok,
aq

"STom" <st***********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
How do you convert a string in C# to decimal?

STom

Nov 16 '05 #3

P: n/a

you can also use the Convert.ToDecimal() method in the
system namespace
-----Original Message-----
How do you convert a string in C# to decimal?

STom
.

Nov 16 '05 #4

P: n/a
remember for constants:

decimal numX = 123.45M;

M for deciMal

"STom" <st***********@hotmail.com> wrote in message
news:#y**************@TK2MSFTNGP14.phx.gbl...
How do you convert a string in C# to decimal?

STom

Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.