I've written a program to fill up a polygon(like in MSPaint). It worked fine in a small area but if i enlarge the area to fill then this error pops out during run time.
here is part of my program
Why can't my recursive function run ??An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
here is part of my program
Code:
public function fill (byval x as integer,byval y as integer,byval colour as integer, byref imagearray(,) as integer)
if imagearray(x,y)=colour then
exit function
else
imagearray(x,y)=colour
fill(x-1,y,colour,imagearray)
fill(x+1,y,colour,imagearray)
fill(x,y-1,colour,imagearray)
fill(x,y+1,colour,imagearray)
end if
end function