首页 > 编程语言 >c# Linq Contains 字符串集合中是否包含某集合中字符

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

时间:2023-06-20 14:13:11浏览次数:39  
标签:c# List Contains list var result 集合

 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));
    }

 

标签:c#,List,Contains,list,var,result,集合
From: https://www.cnblogs.com/hofmann/p/17493499.html

相关文章