469,330 Members | 1,335 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

Convert C# string to decimal

How do you convert a string in C# to decimal?

STom
Nov 16 '05 #1
4 78431
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
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

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
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.

Similar topics

3 posts views Thread by JenHu | last post: by
3 posts views Thread by Petr Jakes | last post: by
3 posts views Thread by JH-PRO | last post: by
3 posts views Thread by Mike Howarth | last post: by
12 posts views Thread by Peter | last post: by
3 posts views Thread by tanishka singh | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.