using System.Collections.Generic;
public static void Main()
string str = "abcadefabba";
Dictionary<int, string> dic = new Dictionary<int, string>();
if (string.IsNullOrWhiteSpace(str))
string curr_str = string.Empty;
if (dic.ContainsKey(idx))
if (curr_str == string.Empty)
if (curr_str.Contains(s.ToString()))
dic[idx] = curr_str + s.ToString();
foreach (var item in dic)
Console.WriteLine(item.Value);
if (item.Value.Length > maxStrLength)
maxStrLength = item.Value.Length;
Console.WriteLine("max str length is: " + maxStrLength.ToString());