using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
var text = "zfabcde224lkfabc51+crsdtab=";
var found = FindPattern(text, 3);
foreach (var kvp in found)
Console.WriteLine("found {0}:{1}", kvp.Key, kvp.Value);
static Dictionary<string, int> FindPattern(string text, int length)
var foundItems = new Dictionary<string, int>();
if (string.IsNullOrEmpty(text) || text.Length <= length)
for (int i = 0; i < text.Length - length; i++)
var pattern = text.Substring(i, length);
if (foundItems.ContainsKey(pattern))
int startIndex = i + length;
startIndex = text.IndexOf(pattern, startIndex);
foundItems[pattern] = patternsFound;