I have a specific lambda what doesn’t seem to want to work properly although the logic seems sound.
index = llCodeList.FindIndex(f => string.Compare(f.Threshold.ToString(), searchText, true ) >= 0);
f.Threshold is an integer value, it seems that the conversion doesn’t happen and it breaks my search function. Can anyone shed some light on this?
Why not ditch the string compare and explicitly check?
Are you sure that the search text is a subset of the threshold number?
Also it may be that you’re not understanding how
string.Compareworks, it won’t check numerical value but string value. For the above ifsearchTextis4and the threshold is-40would match your predicate. My example more explicitly demonstrates the behavior ofstring.Compare(...,...,...) >= 0If you’re trying to find results based on having a greater than or equal to match on threshold and searchText you could do this