Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么此for循环在结束之前退出?_Android_For Loop_Xamarin - Fatal编程技术网

Android 为什么此for循环在结束之前退出?

Android 为什么此for循环在结束之前退出?,android,for-loop,xamarin,Android,For Loop,Xamarin,我有一个for循环,它从JSON文件填充Mymatrix(17,27)。 问题是,当我调试它时,我发现每次I=96,即j=3和k=15时,它都会退出循环。(我还提到len=459) try { JSONObject myjson = new JSONObject(the_json); JSONArray nameArray = myjson.Names();

我有一个for循环,它从JSON文件填充Mymatrix(17,27)。 问题是,当我调试它时,我发现每次I=96,即j=3和k=15时,它都会退出循环。(我还提到len=459)

            try
            {
                    JSONObject myjson = new JSONObject(the_json);
                    JSONArray nameArray = myjson.Names();
                    len = nameArray.Length();
                    for (int i = 0; i < len; i++)
                    {
                        name = nameArray.GetString(i);
                        JSONArray json_array = myjson.GetJSONArray(name);
                        j = (int)(Integer.ValueOf(name)) / 27;  
                        k = (int)(Integer.ValueOf(name)) % 27;      
                        myMatrix[j, k] = json_array.GetDouble(a); //a=0                         
                    }
             }
            catch (JSONException e)
            {
                e.PrintStackTrace();
            }
试试看
{
JSONObject myjson=新的JSONObject(_json);
JSONArray nameArray=myjson.Names();
len=nameArray.Length();
对于(int i=0;i

你能帮我找出为什么我会有这个问题吗

您尝试过干净的构建吗?如果
len=459
并且您说它在
i=96
处中断,这意味着在
循环中抛出了一个异常,您应该有一些日志。如果不使用
包装它中断的位置,请尝试{}catch()
,这样您就可以理解这个案例,我已经这样做了,不会引发异常。。编辑不要用
try catch
包装
循环
包装循环中的逻辑可能提供可以在某处看到的json的ascii版本。github上的要点,或云中共享的某些文件。
            try
            {
                    JSONObject myjson = new JSONObject(the_json);
                    JSONArray nameArray = myjson.Names();
                    len = nameArray.Length();
                    for (int i = 0; i < len; i++)
                    {
                        name = nameArray.GetString(i);
                        JSONArray json_array = myjson.GetJSONArray(name);
                        j = (int)(Integer.ValueOf(name)) / 27;  
                        k = (int)(Integer.ValueOf(name)) % 27;      
                        myMatrix[j, k] = json_array.GetDouble(a); //a=0                         
                    }
             }
            catch (JSONException e)
            {
                e.PrintStackTrace();
            }