I have two lists with the same size. Both contain numbers. The first list is created, and the second is static. Since I have many of the generated lists, I want to find out which one is better. For me, the best list is the one that best matches the link. Therefore, I calculate the difference in each position and add it.
Here is the code:
private static decimal getMatchFitting(IList<decimal> combination, IList<MyClass> histDates)
{
decimal fitting = 0;
if (combination.Count != histDates.Count)
{
return decimal.MaxValue;
}
for (int i = 0; i < combination.Count; i++)
{
fitting += Math.Abs(combination[i] - histDates[i].Value);
}
return fitting;
}
Is it possible a more elegant, but more important and effective way to get the desired amount?
Thanks in advance!
source
share