Unity - A计划(一年有效期) 扫二维码继续学习 二维码时效为半小时

(66评价)
价格: 1299.00元
1对1 答疑即时回复7天无理由退款30天价保提问必答

服务保障

1对1 答疑

提供专属的一对一在线答疑,快速答疑解惑。

即时回复

及时响应学习咨询,帮助解决问题。

7天无理由退款

购买后7天内可申请无理由退款。

30天价保

购买后30天内如遇降价,可申请价保。

提问必答

对于提问做到有问必答,帮您扫清学习过程中的种种障碍

int.Parse的使用问题
塔里木河丶发起了问答2019-07-12
1
回复
2733
浏览

老师我在使用int.prase时出现报错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)
ObjectsInfo.ReadInfo () (at Assets/Scripts/Custom/ObjectsInfo.cs:55)
ObjectsInfo.Awake () (at Assets/Scripts/Custom/ObjectsInfo.cs:14)

代码如下:

 if (type==ObjectType.Drug) {
                int hp = int.Parse(ProArray[4]);
                int mp = int.Parse(ProArray[5]);
                int price_sell = int.Parse(ProArray[6]);
                //print(ProArray[6]);
                int price_buy = int.Parse(ProArray[7]);

我在使用prite输出之后返回的值是50,但是总是出现这个报错

所有回复
  • 老师_Trigger • 2019-07-13

    同学你好,可以参考一下:

    https://blog.csdn.net/dxb601/article/details/73089018

    https://blog.csdn.net/yuxuac/article/details/51960042

    另外可能是方法调用的先后顺序问题,也就是存在这个方法被调用了两次。第一次调用的时候需要提前加载的一些参数没有加载。

    还有-5条回复,点击查看
    你还没有登录,请先登录或注册!
发表回复
你还没有登录,请先 登录或 注册!