Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to cast string to double

0 views
Skip to first unread message

Ernesto Herrera

unread,
Jul 17, 2002, 9:26:14 AM7/17/02
to
Hi,
As you can see, I am new to C#. I have a text box asp control in a form, and
the information I get from it is a number.

how do I convert from string to double or any other number? In C we use to
have atoi, and VB we had the tons of convertion functions.

Thanks
Ernesto

Jochen Kalmbach

unread,
Jul 17, 2002, 9:28:48 AM7/17/02
to
Ernesto Herrera wrote:

> how do I convert from string to double or any other number? In C we
> use to have atoi, and VB we had the tons of convertion functions.

string str = "12.2";
double dbl;


dbl = double.Parse(str);

or

Convert.ToDouble(str);

--
Greetings
Jochen

Joe Feser

unread,
Jul 17, 2002, 9:32:24 AM7/17/02
to
You will need to trap for a possible conversion error but here it is

string textbox = "5";

double testdbl = System.Double.Parse(textbox);


--
Joe Feser
Fesersoft
http://www.fesersoft.com/
.Net, XML, XSLT, SQL
Free Code, Articles and Information.


"Ernesto Herrera" <ern...@bellsouth.net> wrote in message
news:jceZ8.49879$1q2.3...@e3500-atl2.usenetserver.com...

Jens Gruschel

unread,
Jul 17, 2002, 9:34:47 AM7/17/02
to
> how do I convert from string to double or any other number? In C we use to
> have atoi, and VB we had the tons of convertion functions.

.NET provides tons of conversion function, too. You could use
Convert.ToDouble or double.Parse / double.TryParse

Jens

Ernesto Herrera

unread,
Jul 17, 2002, 2:13:08 PM7/17/02
to
Thank you guys.
Ernesto

"Jens Gruschel" <grus...@esteam.de> wrote in message
news:um9pNaZLCHA.1608@tkmsftngp09...

0 new messages