using System.Collections.Specialized;
static StringCollection Fiddle(string sourceString, int patternLength)
StringCollection myCol = new StringCollection();
var lastPatternIndex = sourceString.Length - patternLength;
throw new ArgumentOutOfRangeException("patternLength","pattern lenght must be positive.");
if (lastPatternIndex <= 0)
throw new ArgumentOutOfRangeException("sourceString","sourceString must be longer then pattern length.");
if (lastPatternIndex > Int32.MaxValue)
throw new ArgumentOutOfRangeException("sourceString","sourceString must be shotter then max int value, for make Substring working.");
for (var index = 0; index <= lastPatternIndex; ++index)
var pattern = sourceString.Substring(index, patternLength);
for (var subindex = 0; subindex < index; ++subindex)
if (pattern == sourceString.Substring(subindex, patternLength))
if (!myCol.Contains(pattern))
public static void Main()
var result = Fiddle("zfabcde224lkfabc51+crsdtab=", 3);
foreach(var line in result)