Re: [問題] 字串比對
不知道有沒有誤解你的意思
string[] addressDatas = new string[0];
string pUserInput = "";
string[] keyWords = pUserInput.Split (' ', ',');
var result = from tar in addressDatas
where keyWords.Count (r => tar.Contains (r)) > 1//符合的數量
select tar;
或者進階一點
string[] addressDatas = new string[0];
string pUserInput = "";
string[] keyWords = pUserInput.Split (' ', ',');
var result = from tar in addressDatas
let num = keyWords.Count (r => tar.Contains (r))
where num > 0
let anonymous = new {nNum = num,address = tar}
orderby anonymous.nNum descending
select anonymous;
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.110.33.129
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1448130369.A.37B.html
討論串 (同標題文章)
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章