c# Linq Contains 字符串集合中是否包含某集合中字符

发布时间 2023-06-20 14:09:38作者: hofmann
 public class UnitTest1
    {
        [Fact]
        public void Test1()
        {
            var list_A = new List<string> { "MU", "CA", "PA" };
            var list_B = new List<string> { "A000MU-100002", "A000CB-100004", "A000GU-100006" };

            var result = list_B.Where(q => ListTypeFilter(q, list_A));
            var temp = result.ToList();

        }

        static bool ListTypeFilter(string hand, List<string> filters) => filters.Any(filter => hand.Contains(filter));
    }