索引超出数组的范围 [英] Index outside the bounds of an array

查看:79
本文介绍了索引超出数组的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public bool processScreenCoord(Point screenCoord, Bitmap printscreen, List<LootableItem> lootableItems, List<AttackableMonster> attackableMonsters,
       bool[,] blacklistedPixels, ClickTracker ct, bool chkGreen, bool chkBlack, bool chkItem, int blacklistOffsetX, int blacklistOffsetY, int[] intData,
       bool chkWhites, bool chkReds)

       {

           {
               {
                   //if (blacklistedPixels.Count(p => p.X == screenCoord.X && p.Y == screenCoord.Y) > 0)
                   if (blacklistedPixels[screenCoord.X + blacklistOffsetX, screenCoord.Y + blacklistOffsetY] == true)
                   {
                       return false;
                   }

                   if (searchScreenCoord(screenCoord, printscreen, blacklistedPixels, lootableItems, attackableMonsters, ct,
                       chkGreen, chkBlack, chkItem, blacklistOffsetX, blacklistOffsetY, intData, chkWhites, chkReds))
                   {
                       return true;
                   }

               }


               return false;

           }
       }





我的索引超出范围数组,我不知道如何纠正它



我尝试过:



我尝试过使用try / catch语句,但它根本不会添加没有错误因此我甚至无法调试:(



I am getting index outside the bounds of an array and I have no idea how to correct it

What I have tried:

I have tried using a try/catch statement but it simply wouldn't add without errors thus I couldn't even debug :(

推荐答案

A try / catch 从不纠正错误。

我的建议:

删除 try / catch ,并使用调试器,检查数组大小和您使用的索引。

如果无法启动调试器,您至少可以打印信息或将其转储到一个日志文件。



你是唯一可以做某事的人,因为错误取决于你的数据。
A try/catch never correct errors.
My advice:
remove the try/catch, and use the debugger, check the array size and the index you use.
If you can't launch the debugger, you can at least print the information or dump it in a log file.

You are the only one, who can do something, because the error depend on your data.


这篇关于索引超出数组的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆