c# - How to find the nearest string in a List in LINQ? -
if want find exact match or next nearest string. using sql, can :
select top 1 * table code >= @searchcode order code how might achieve using linq , list of records.
i expecting able like:
var find = listds.where(c => c.code >= searchcode).first(); but can't compare strings way.
note code alpha string, letters, numbers, symbols, whatever..
nearest means if have list containing "england", "france", "spain", , search "france" "france". if search "germany" "spain".
here simple code may you
list<string> ls = new list<string>(); ls.add("ddd"); ls.add("adb"); var vv = p in ls p.startswith("a") select p; select element starting string "a"
Comments
Post a Comment