how to convert www.text to int

im trying to compare my app version with the current version using www object. it works fine on ios but giving me error in android. its weird as why this is not a problem in ios but returns error in android.

my code:

WWW Version = new WWW( "url link here");
yield return Version;
int pass = 1;
        if(!string.IsNullOrEmpty(Version.error)) {
            print( "Error downloading Version Number");
            pass = 0;
        }

if (pass == 1) {
            if (CurrentVersion < int.Parse (Version.text)) {               
                init.InitGame ();           
            }

it gave me this error in editor

FormatException: Input string was not in the correct format
System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Int32.cs:629)

Log your Version.text before the parse and check if the value is different on Android ?

Use TryParse instead of Parse.
Also, the ‘pass’ variable only clutters your code. Use if/else instead.

Make sure your Version.text string is in correct format (no letters, symbols, etc).
Also try this Convert.ToInt16(Version.text) or Convert.ToInt32(Version.text)

using System;

lol silly me, the url for android was wrong. that explains why i could run the script on ios. thanks anyway guys!

Nevertheless you should 1) check the WWW instance for errors and 2) use TryParse. :wink: