//
        //山谷点结构;
        public struct SG_Center_Point
        {
            public double X;//存放点的X坐标值;
            public double Y;//存放点的Y坐标值;
            public double Z;//存放点的Z坐标值;
            public int RowNum;//存放点的行号;
            public int ColNum;//存放点的列号;
            public bool If_Follow;//判断是否被跟踪过,跟踪过为true,否则为false;
            public int List_Num;
        };
这个是我自己定义的一个结构体;private void Max()
        {            Chosed_Point = new ArrayList();
            
            int j = 0;
            SG_Center_Point Max_Point = new SG_Center_Point(); 
            
            for (int i = 0; i < List_SG.Count; i++)///List_SG是个链表,一般size在30000以上
            {
                SG_Center_Point Temp_Point = (SG_Center_Point)List_SG[i];
                if (Temp_Point.If_Follow == false)
                {
                    if (Temp_Point.Z > Max_Point.Z)
                    {
                        Max_Point = Temp_Point;
                        j = i;
                    }
                }
            }
            //
            //如果Max_Point为空;跳出函数;
            if (Max_Point.X == 0.0 && Max_Point.ColNum == 0 && Max_Point.If_Follow == false && Max_Point.List_Num == 0 && Max_Point.RowNum == 0 && Max_Point.Y == 0.0 && Max_Point.Z == 0.0) //
            {
                return;
            }
            //
            //如果“Max_Point”不为空,将List_SG链表里相应位置的“SG_Center_Point”的“If_Follow”改为true;
            if (Max_Point.X != 0.0 && Max_Point.If_Follow == false && Max_Point.Y != 0.0 && Max_Point.Z != 0.0)
            {
                SG_Center_Point  _point = Max_Point;
                _point.If_Follow = true;
                _point.List_Num = j;
                if (j == List_SG.Count - 1)
                {
                    List_SG.RemoveAt(j);
                    List_SG.Add(_point);
                }
                if (j != List_SG.Count - 1)
                {
                    List_SG.RemoveAt(j);
                    List_SG.Insert(j, _point);
                }
            }
            //
            //如果选取的“Max_Point”为边框上的点;继续搜索最大高程值点,直到点不在边框上;
            if (Max_Point.RowNum == 0 || Max_Point.RowNum == RowCou - 1 || Max_Point.ColNum == 0 || Max_Point.ColNum == ColCou - 1)
            {
                Max();
            }
            //
            //如果选取的“Max_Point”不在边框上;将点存入链表“Chosed_Point”;并以此点位开始节点,搜索下一点;
            if (Max_Point.RowNum != 0 && Max_Point.RowNum != RowCou - 1 && Max_Point.ColNum != 0 && Max_Point.ColNum != ColCou - 1)
            {
                Chosed_Point.Add(Max_Point);
                Gu_Line.Add(Chosed_Point);
                
                Max();
            }
            
        }
这个函数一运行就提示我说堆栈溢出;请大家帮看看是哪出了问题!谢谢大家了Chosed_Point、Gu_Line都是我自己定义的链表!