【问题标题】:I want compare two string and want to get possible matches [closed]我想比较两个字符串并希望获得可能的匹配项[关闭]
【发布时间】:2021-02-04 17:21:21
【问题描述】:

sb.Qualilfication_Master.First().Qual_List 包含字符串值,例如 "B.C.A,M.C.A,B.B.A" 和 txtQualification.text 包含类似 "B.C.A, M.Com" 的字符串 我想匹配以上两件事

var sendnoti = (from p in db.Reg_JobSeeker_Masters where p.Qualification_Masters.First().Qual_List.Contains(txtQualification.Text)select p).ToList();

【问题讨论】:

  • 请提供相关变量的 C# 类型。请解释一下编程术语中“我要匹配以上两件事”的含义。

标签: c# asp.net linq


【解决方案1】:

如果我没看错——并且你想找到两个列表共有的字符串——那么你可以使用 intersect 方法。

【讨论】:

    【解决方案2】:

    我只是假设 txtQualification.Text 是 List<string>,所以在这种情况下,您可以像这样正确 -

    var sendnoti = (from p in db.Reg_JobSeeker_Masters where p.Qualification_Masters.First().Qual_List.Any(ql => txtQualification.Text.Contains(ql))select p).ToList();
    

    【讨论】:

      猜你喜欢
      • 2021-12-20
      • 2021-10-12
      • 1970-01-01
      • 2021-05-05
      • 2012-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-15
      相关资源
      最近更新 更多