The problem is as follows:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers.
Using Project Euler to stretch my C# learning, I solved problem #4 with the code below. I ran this in a console app to get the answer. How can I improve my code?
class PalindromNumber
{
public string GetPalindromeNumber(int maxNumber = 999)
{
bool breakOut = false;
int test=0;
int left = 0;
int right = 0;
int biggestNumber = 0;
string returnString=string.Empty;
for (left=maxNumber; left >= 0; left--)
{
for(right=maxNumber; right >= 0; right--)
{
test = left * right;
string testNumberAsString = Convert.ToString(test);
string reverse = string.Empty;
for (int index = testNumberAsString.Length; index > 0; index--)
{
reverse += testNumberAsString[index-1];
}
breakOut = (testNumberAsString == reverse && Convert.ToString(left).Length == 3 && Convert.ToString(right).Length == 3);
if (breakOut )
{
break;
}
}
if (test>biggestNumber)
{
biggestNumber = test;
returnString = $"Palindrome: {test}, Left: {left}, Right: {right}";
}
}
return returnString;
}
}