Convert int to string and back again

Hi all, I’m having a problem after I convert one of my int’s to a string…I can’t get it to convert back to an int! Here’s some sample code to show you what i’m dealing with.

var price : int;

function IntToString() {

function StringToInt() {
price = System.Int32.TryParse(price); <<<ERROR HERE

I’m getting the error “No appropriate version of int.TryParse for the argument list ‘(int)’ was found.”

Can someone give me an idea what I’m doing wrong? Thank you!

Here you go:

 var nu1: int = 100;
 var str: String ="";
 var nu2: int;

 // Convert int to string
 str= nu1.ToString();

 // Convert string to int


According to the documentation of TryParse, it wants two parameters, a string and an output int … see:

Did you perhaps mean to use the Parse() method? See:

This however would also not work as in your code you are passing in “price” which is an int and both Parse() and TryParse() expect a String as input.