hussam.al
10-08-2004, 02:37 PM
public class grafixCorrupt
{
public int selectWord(string[] dictionary, string candidate)
{
int bestMatch; // Best matching word
int bestMatchIndex; // Index of the best matching word
int InstanceMatch; // How many charcters does an array element match
bestMatch = 0;
bestMatchIndex = -1;
for (int i = 0; i < dictionary.Length ; i++)
{
InstanceMatch = 0;
if (dictionary[i] != null)
for (int j = 0; j < dictionary[i].Length; j++)
if (j < candidate.Length)
if (dictionary[i][j] == candidate[j])
InstanceMatch++;
if (InstanceMatch > bestMatch)
{
bestMatch = InstanceMatch;
bestMatchIndex = i;
}
}
return bestMatchIndex;
}
}
{
public int selectWord(string[] dictionary, string candidate)
{
int bestMatch; // Best matching word
int bestMatchIndex; // Index of the best matching word
int InstanceMatch; // How many charcters does an array element match
bestMatch = 0;
bestMatchIndex = -1;
for (int i = 0; i < dictionary.Length ; i++)
{
InstanceMatch = 0;
if (dictionary[i] != null)
for (int j = 0; j < dictionary[i].Length; j++)
if (j < candidate.Length)
if (dictionary[i][j] == candidate[j])
InstanceMatch++;
if (InstanceMatch > bestMatch)
{
bestMatch = InstanceMatch;
bestMatchIndex = i;
}
}
return bestMatchIndex;
}
}