类似于linq find in which position is my object in List,除了他接受的答案是在对象级别进行评估。
说我有
public interface IFoo{
string text {get;set;}
int number {get;set;}
}
和
public class Foo : IFoo{
public string text {get;set;}
public int number {get;set;}
}
现在我有一个IFoo
这样的列表集合:
public IList<IFoo> Foos;
Foos
我想编写一个基于属性值和/或值(例如,text
或number
在这种情况下)带回索引的方法,以便我可以执行以下操作:
var fooIndexes = Foos.GetIndexes( f => f.text == "foo" && f.number == 8 );
我该怎么写?