0
我寫了一個遞歸函數。出於某種原因,它在第一次運行後不會自行調用。它只是從循環中取得下一個項目而不會更深入。我正在使用Visual Studio 10,並且缺乏睡眠。未能遞歸
public IEnumerable<string> GeneratePath(int depth)
{
int presentDepth = depth;
char currentPosition = this.workingPath[presentDepth];
presentDepth++;
foreach (char nextPosition in this.moveTable.GetPossibleNextPositions(currentPosition))
{
this.workingPath[presentDepth] = nextPosition;
if (presentDepth < (ChessPiece.targetDepth - 1))
{
Console.WriteLine("At least this wasn't ignored:{0}", new string(this.workingPath));
this.GeneratePath(presentDepth);
}
else
yield return new string(this.workingPath);
}
}