我正在尝试搜索第一个列表项的索引,它的值为"hello",它是指数高于15。 显然不是这样,因为当我引用 p 时,我引用的是 value,而不是 string 本身(IndexOf 查找"hello" 在列表中第一次出现的索引,因为 p == string)
int soucasny = list1.FindIndex(p => p == "hello" || list1.IndexOf(p) > 15);
有没有办法达到预期的效果?大概选择?
最佳答案
您可以为 IndexOf
指定起始索引
int soucasny = list1.IndexOf("hello", 15);
关于c# - 按索引列表搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27389379/