That is because you are recursively calling yourself. Your Compare
method calls itself which calls itself which calls itself... At some point you run out of stack space. Inside your Compare
method you surely don't want to call yourself. Replace that call with the code you actually want to call. At some point somebody has to have the logic to do the actual comparison and that is what goes into this Compare
method.
how to fix Exception of type 'System.StackOverflowException' was thrown.' in c#
Dineshkumar.S
456
Reputation points
In my C# windows application when i try to execute a method it throws me the Exception of type 'System.StackOverflowException' was thrown.' exception how to fix it and i am getting the infinite loop at the below code :
public bool Compare(string answerFile, string correctFile, bool cellDiffFlag,
out bool isCorrect, out string strOut)
{
return Compare(answerFile, correctFile, cellDiffFlag, out isCorrect, out strOut);
}
Accepted answer
-
Michael Taylor 57,396 Reputation points
2023-03-06T15:49:19.7366667+00:00