LINQ: …Where(x => x.Contains(string that start with “foo”))

前端 未结 5 947
南旧
南旧 2021-01-04 19:06

Given a collection of the following class:

public class Post
{
    ...
    public IList Tags { get; set; }
}

Is there an easy

5条回答
  •  醉梦人生
    2021-01-04 19:32

    I believe this will work for what you're trying to do.

    posts.Where(p => p.Tags.Any(t => t.StartsWith("foo")))

提交回复
热议问题