【发布时间】:2015-11-25 13:12:41
【问题描述】:
我有字符串列表。如果列表包含该部分字符串,则找出该项目的索引。请查看代码以获取更多信息。
List<string> s = new List<string>();
s.Add("abcdefg");
s.Add("hijklm");
s.Add("nopqrs");
s.Add("tuvwxyz");
if(s.Any( l => l.Contains("jkl") ))//check the partial string in the list
{
Console.Write("matched");
//here I want the index of the matched item.
//if we found the item I want to get the index of that item.
}
else
{
Console.Write("unmatched");
}
【问题讨论】: