Thread overview
Conversion (silly question, sorry)
Jan 01, 2008
renoir
Jan 02, 2008
Derek Parnell
Jan 02, 2008
Bill Baxter
January 01, 2008
Sorry for the silly question:
how can i convert from string to int? And viceversa from int to string?
Thx.
January 02, 2008
On Tue, 01 Jan 2008 18:32:32 -0500, renoir wrote:

> Sorry for the silly question:
> how can i convert from string to int? And viceversa from int to string?
> Thx.

Have a look at the std.conv module.

   string s;
   double f;

   s = std.conv.to!(string)(23.45);
   f = std.conv.to!(double)(s);

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
January 02, 2008
"renoir" <renato@rexlen.it> wrote in message news:fleiig$28gg$1@digitalmars.com...
> Sorry for the silly question:
> how can i convert from string to int? And viceversa from int to string?
> Thx.

If you're using D1, use std.string.toString to convert most basic types to strings and std.conv.toInt to convert from strings to ints.


January 02, 2008
Jarrett Billingsley wrote:
> "renoir" <renato@rexlen.it> wrote in message news:fleiig$28gg$1@digitalmars.com...
>> Sorry for the silly question:
>> how can i convert from string to int? And viceversa from int to string?
>> Thx.
> 
> If you're using D1, use std.string.toString to convert most basic types to strings and std.conv.toInt to convert from strings to ints. 

Or get std2 from dsource and use things like std2.conv.to!(double)(s).

http://www.dsource.org/projects/std2

--bb