using System.Collections.Generic;
public static void Main()
string inputString = "zf3kabxcde224lkzf3mabxc51+crsdtzf3nab=";
Dictionary<string,int> patterns = FindMultipleOccurences(inputString, patternLength);
foreach(var pattern in patterns)
Console.WriteLine(pattern.Key + " : " + pattern.Value.ToString());
Console.WriteLine(ex.Message);
public static Dictionary<string, int> FindMultipleOccurences(string inputString, int patternLength)
Dictionary<string, int> patterns = new Dictionary<string, int>();
if(inputString.Length < patternLength)
throw new ArgumentOutOfRangeException("Pattern length must be less than or equal to input string length!");
for(int i = 0; i <= inputString.Length - patternLength; i++)
string patternFound = inputString.Substring(i, patternLength);
if(patterns.ContainsKey(patternFound))
patterns[patternFound] += 1;
patterns.Add(patternFound, 1);
return patterns.Where(p => p.Value > 1).ToDictionary(p => p.Key, p => p.Value);