LIKE operator in LINQ

前端 未结 14 1136
一生所求
一生所求 2020-11-27 16:29

Is there any way to compare strings in a C# LINQ expression similar to SQL\'s LIKE operator?

Suppose I have a string list. On this list I want to search

14条回答
  •  臣服心动
    2020-11-27 16:52

    A simple as this

    string[] users = new string[] {"Paul","Steve","Annick","Yannick"};    
    var result = from u in users where u.Contains("nn") select u;
    

    Result -> Annick,Yannick

提交回复
热议问题