PDA

View Full Version : Sorry another questions


yeen83
08-09-2002, 09:33 AM
Sorry there is another questions.How to convert the string into integer so that i can use it to add.

tryandcatch
08-09-2002, 09:41 AM
var str="10"
int x=9
int y=x+Integer.parseInt(str)

yeen83
08-09-2002, 10:04 AM
Thanks

mordred
08-09-2002, 10:05 AM
That's JavaScript?

I would suggest one of the following:

var x = parseInt(str, 10);
var x = Number(str);
var x = str * 1;

Although the latter is just using the implicit conversion abilities of JavaScript.