rendered paste bodystatic void Main(string[] args)
{
StringBuilder tempPal = null;
List<string> pd = new List<string> { };
string input = "FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshallnothavediedinvainthatthisnationunsderGodshallhaveanewbirthoffreedomandthatgovernmentofthepeoplebythepeopleforthepeopleshallnotperishfromtheearth";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.Length; i++)
{
if (i % 1 == 0)
sb.Append(' ');
sb.Append(input[i]);
}
string formatted = sb.ToString();
string[] bigString = formatted.ToString().Split(' ');
for (int i = 1; i < bigString.Length; i++)
{
tempPal = new StringBuilder();
string firstLetter = bigString[i];
tempPal.Append(firstLetter);
string testPal = "";
for (int j = i + 1; j < bigString.Length; j++)
{
testPal = tempPal.ToString() + bigString[j];
if (testPal == Reverse(testPal))
{
pd.Add(testPal);
}
tempPal.Append(bigString[j]);
}
tempPal = null;
}
string longest= "";
for(int i = 0; i<pd.Count; i++)
{
if (pd[i].Length > longest.Length)
{
longest = pd[i];
}
}
Console.WriteLine(longest);
Console.ReadKey();
}
public static string Reverse(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}