【发布时间】:2015-03-14 17:46:22
【问题描述】:
我有一个元组列表,其中包含我想在我的文本文件对象 (newFile) 的 Queue 属性中检查的字符串组合。 Queue 是一个名为 Lines 的字符串队列。
我不确定元组列表是否可行,但如果在任何行中找到任何元组的 Item1 和 Item2(按 Item1 然后 Item2 顺序),我只想要一个真实的结果。这是我最好的镜头,但我不知道如何编写 LINQ 语句。
List<Tuple<string,string>> codes = new List<Tuple<string, string>>()
{
new Tuple<string, string>("01,", "02,"),
new Tuple<string, string>("02,", "03,"),
new Tuple<string, string>("03,", "88,"),
new Tuple<string, string>("88,", "88,"),
new Tuple<string, string>("89,", "90,")
};
bool codesFound = newFile.Lines
.Any(Regex.Match(codes.Select(x => (x.Item1 + "(.*)" + x.Item2)));
【问题讨论】: