c# 嵌套list怎么寻找关键字符串的子list
这样的代码找到的是空的list
string[] datStr = File.ReadAllLines(LocalDestinationFolder + "\\" + "20231031143000.text");//largeBytes
var lists = new List<List<string>>();//lists
string tmpStr = string.Empty;//marker
var tmpLst = new List<string>();//tmpLst
var KeyWord=string.Empty;
foreach (var datstr in datStr)
{
if (datstr == tmpStr)
{
lists.Add(tmpLst);
tmpLst = new List<string>();
}
else
{
tmpLst.Add(datstr);
}
}
lists.Add(tmpLst);
if (!string.IsNullOrEmpty(KeyWord))
lists = lists.Where(list => list.Contains(KeyWord)).ToList();