我有这个错误怎么解决? “grahamscandatamovement.exe”中出现了类型'system.indexoutofrangeexception'的未处理异常。 [英] HI I have this error how to fix ? "an unhandled exception of type 'system.indexoutofrangeexception' occurred in grahamscandatamovement.exe"

查看:63
本文介绍了我有这个错误怎么解决? “grahamscandatamovement.exe”中出现了类型'system.indexoutofrangeexception'的未处理异常。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用我的程序时遇到这个问题



在此代码中:





i have this problem when i use my program

In this Code :


private void findSmallestPolygon()
{

    int clockwise = 1;
    int countclockwise = -1;
    int l = 0,m = 1,i = 2;

    finalPointArray = new int[count];
    //take two point
    finalPointArray[l] = 1;
    finalPointArray[m] = 1;
    Pen redPen;
    SolidBrush blueBrush = new SolidBrush(Color.White);

    redPen = new Pen(Color.Red,2);

    //draw line
    dc.DrawLine(redPen, new Point(xcordinate[0], ycordinate[0]), new Point(xcordinate[1], ycordinate[1]));









这是一个问题:





Here IS A Problem With :

finalPointArray[m] = 1;





请点击!



什么我试过了:



i试图解决它,但我不能!



请帮助我



Olease HElp !

What I have tried:

i tried to fix it but i cant !

Please Help ME

推荐答案

初始化 finalPointArray 持有 count 项目数量。您没有显示计数是什么,但可能太小而无法容纳由变量 m 定义的项目。 />


最好使用调试器并查看变量的实际值以便更好地解释。还要记住,索引从0开始,所以如果你有3个项目,索引将是0,1和2.



作为旁注,我建议定义方法内的变量。如果需要从方法外部获取信息,则将其作为参数传递通常是一种好习惯。这使程序更容易调试,修改和理解
You initialize the finalPointArray to hold count amount of items. You don't show what the count is but probably too small to hold an item defined by variable m.

Best to use the debugger and see the actual values of the variables to better interpret. Also remember that indexing starts from 0 so if you have 3 items the indexes will be 0,1, and 2.

As a side comment, I would advise to define the variables inside the method. If information is needed from outside the method, it's often a good practice to pass it as a parameter. This makes the program easier to debug, modify, and understand


这篇关于我有这个错误怎么解决? “grahamscandatamovement.exe”中出现了类型'system.indexoutofrangeexception'的未处理异常。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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