© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
34 replies
Faker

✅ Separate local function with explicit 'return' statement

string[] words = {"racecar" ,"talented", "deified", "tent", "tenet"};

Console.WriteLine("Is it a palindrome?");
foreach (string word in words) 
{
    Console.WriteLine($"{word}: {IsPalindrome(word)}");
}

bool IsPalindrome(string word)
{
    int startPointerIndex = 0;
    int endPointerIndex = word.Length - 1;
    for (int i = 0; i < word.Length - 1; i++)
    {
        if (word[startPointerIndex] == word[endPointerIndex] && startPointerIndex < endPointerIndex)
        {
            continue;
        }
        else
        {
            return false;
        }

        startPointerIndex++;
        endPointerIndex--;
    }

    return true;
}
string[] words = {"racecar" ,"talented", "deified", "tent", "tenet"};

Console.WriteLine("Is it a palindrome?");
foreach (string word in words) 
{
    Console.WriteLine($"{word}: {IsPalindrome(word)}");
}

bool IsPalindrome(string word)
{
    int startPointerIndex = 0;
    int endPointerIndex = word.Length - 1;
    for (int i = 0; i < word.Length - 1; i++)
    {
        if (word[startPointerIndex] == word[endPointerIndex] && startPointerIndex < endPointerIndex)
        {
            continue;
        }
        else
        {
            return false;
        }

        startPointerIndex++;
        endPointerIndex--;
    }

    return true;
}

Hello guys, can someone explain why my IDE yells at me to use an "explicit" return statement pls. What is it trying to convey and why should I use it?
616DF90F-7850-49BA-A740-5F4B6423B9D6.png
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

Struct with explicit layout
C#CC# / help
3y ago
Help with Implicit Explicit operators
C#CC# / help
4y ago