private int MatchingConsecutiveCharacters(string word, Node curNode)
{
int matches = 0;
int minLength = 0;
//see which string is smaller and save it's lenght
//when cycling throught the two strings we won't go any further than that
if (curNode.Label.Length >= word.Length)
minLength = word.Length;
else if (curNode.Label.Length < word.Length)
minLength = curNode.Label.Length;
if(minLength > 0)
//go throught the two streams
for (int i = 0; i < minLength; i++)
{
//if two characters at the same position have the same value we have one more match
if(word[i] == curNode.Label[i])
matches++;
else
//if at any position the two strings have different characters break the cycle
break;
}
//and return the current number of matches
return matches;
}