© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
2 replies
KleinRiese

✅ Problem with a Recursion Function

I am currently programming a Snake-Clone and want to count the Parts(length of the tail) of the snake. Each part has a reference to the next part, called "next tail part". Is the recursion-function the problem, or something else?
I am Printing the Result, by calling the function in the Debug.Log function : Console.WriteLine(DebugSnakeParts());

Function:
private int DebugSnakeParts()
{
if(nextTailPart == null)
{
return 1;
}else
{
return DebugSnakeParts() + 1;
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ C# Recursion Output problem
C#CC# / help
3y ago
recursion
C#CC# / help
16mo ago
recursion
C#CC# / help
4y ago
Little problem with a function for a total newbie ...
C#CC# / help
2y ago