I write a DFS(depth first search) founction in my C# project A, and it runs OK. Then I build a new c# project B, which has more lines of codes than A. When I run the same founction in project B with the same input data,my VS2008 shows that there is a stack-overflow error.
Can I change the size of Stack in C#?
The founction's name is :FindBlocksFounction().
Codes which cause stack-overflow:
int tempx = nowx + dir[i, 0];
int tempy = nowy + dir[i, 1];
if (tempx < 0 || tempy < 0 || tempx >= m_Bitmap.Height || tempy >= m_Bitmap.Width)
continue;
int next;
next = PointList.FindIndex(t =>
{
if (t.x == tempx && t.y == tempy)
return true;
else
return false;
});//It seems like that FindIndex() in List<> costs some stack room.
if (next == -1)
continue;
if (color[next] == 0)
{
FindBlocksFounction(next);
}