We have an array having items from a ienumerator object. One of the field is of type float. While trying to get the index of an item using Array.FindIndex on the float field, It is working fine if it is having 2 digits precisions (ex: 23.34), but if the precession is more than 2 digits (ex: 23.345) it is returning -1.
following is what we are doing:
var items = customer.orders.OrderBy(o => o.price).ToArray();
foreach (var order in object.orders)
{
int itemIndex= Array.FindIndex(items , i => i.price == order.price);
}
in the above example, if the price = 50.64 then Array.FindIndex returns exact index from the items array. But if the price = 50.654 (with more than 2 digits of precesion) it is returning -1 as index (means item not found in array).
Any simple way to solve this issue???
Thanks!!!