You're talking about some fuzzy logic there - first and most importantly you
need to define exactly what "most similar" means, between whatever objects
you're comparing. From there you would probably implement IComparer for the
type and a custom collection that would allow this fuzzy lookup.
For example for String, you could define "most similar" as the first match
less than or equal to a given value, then using a sorted set of values
(untested code here)...
string find = "d";
string[] values = { "a", "c", "e" };
string match = null;
Array.Sort(values);
foreach(string s in values)
{
if (s.CompareTo(find) <= 0)
{
match = s;
break;
}
}
"Hyun-jik Bae" wrote:
Is there any way how to get the item which has the most similar key in
key-value collection object such as Dictionary<or SortedDictionary<>
although there is no matching key? If there is none, is there any
substitution class for enabling this?
Please reply. Thanks in advance.
Hyun-jik Bae