作者bantime (景)
看板C_Sharp
标题Re: [问题] 字串比对
时间Sun Nov 22 02:26:06 2015
不知道有没有误解你的意思
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://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1448130369.A.37B.html